Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
25bec8c8
Commit
25bec8c8
authored
Aug 05, 1992
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sometimes, recvfrom() returns an empty address; this is not an error.
Also, get rid of makepair() in favor of mkvalue().
parent
099d9233
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
26 deletions
+10
-26
Modules/socketmodule.c
Modules/socketmodule.c
+10
-26
No files found.
Modules/socketmodule.c
View file @
25bec8c8
...
...
@@ -181,28 +181,6 @@ setipaddr(name, addr_ret)
}
/* Generally useful convenience function to create a tuple from two
objects. This eats references to the objects; if either is NULL
it destroys the other and returns NULL without raising an exception
(assuming the function that was called to create the argument must
have raised an exception and returned NULL). */
static
object
*
makepair
(
a
,
b
)
object
*
a
,
*
b
;
{
object
*
pair
=
NULL
;
if
(
a
==
NULL
||
b
==
NULL
||
(
pair
=
newtupleobject
(
2
))
==
NULL
)
{
XDECREF
(
a
);
XDECREF
(
b
);
return
NULL
;
}
settupleitem
(
pair
,
0
,
a
);
settupleitem
(
pair
,
1
,
b
);
return
pair
;
}
/* Create a string object representing an IP address.
This is always a string of the form 'dd.dd.dd.dd' (with variable
size numbers). */
...
...
@@ -231,13 +209,18 @@ makesockaddr(addr, addrlen)
struct
sockaddr
*
addr
;
int
addrlen
;
{
if
(
addrlen
==
0
)
{
/* No address -- may be recvfrom() from known socket */
INCREF
(
None
);
return
None
;
}
switch
(
addr
->
sa_family
)
{
case
AF_INET
:
{
struct
sockaddr_in
*
a
=
(
struct
sockaddr_in
*
)
addr
;
return
makepair
(
makeipaddr
(
a
),
newintobject
((
long
)
ntohs
(
a
->
sin_port
)));
return
mkvalue
(
"Oi"
,
makeipaddr
(
a
),
ntohs
(
a
->
sin_port
));
}
case
AF_UNIX
:
...
...
@@ -251,6 +234,7 @@ makesockaddr(addr, addrlen)
default:
err_setstr
(
SocketError
,
"return unknown socket address type"
);
return
NULL
;
}
}
...
...
@@ -365,7 +349,7 @@ sock_accept(s, args)
return
socket_error
();
/* Create the new object with unspecified family,
to avoid calls to bind() etc. on it. */
res
=
m
akepair
(
(
object
*
)
newsockobject
(
newfd
,
res
=
m
kvalue
(
"OO"
,
(
object
*
)
newsockobject
(
newfd
,
s
->
sock_family
,
s
->
sock_type
,
s
->
sock_proto
),
...
...
@@ -624,7 +608,7 @@ sock_recvfrom(s, args)
return
socket_error
();
if
(
resizestring
(
&
buf
,
n
)
<
0
)
return
NULL
;
return
m
akepair
(
buf
,
return
m
kvalue
(
"OO"
,
buf
,
makesockaddr
((
struct
sockaddr
*
)
addrbuf
,
addrlen
));
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment