Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
PyPy
pypy
Commits
eb63b07ea99a
Commit
673120d8
authored
May 24, 2014
by
Alex Gaynor
Browse files
merged upstream
parents
71a9f28d192f
4c74306d3280
Changes
1
Hide whitespace changes
Inline
Side-by-side
rpython/rlib/rsocket.py
View file @
eb63b07e
...
...
@@ -22,6 +22,8 @@ from rpython.rlib.rthread import dummy_lock
from
rpython.rtyper.lltypesystem
import
lltype
,
rffi
from
rpython.rtyper.lltypesystem.rffi
import
sizeof
,
offsetof
INVALID_SOCKET
=
_c
.
INVALID_SOCKET
from
rpython.rlib
import
jit
def
mallocbuf
(
buffersize
):
return
lltype
.
malloc
(
rffi
.
CCHARP
.
TO
,
buffersize
,
flavor
=
'raw'
)
...
...
@@ -592,6 +594,7 @@ class RSocket(object):
addrlen_p
[
0
]
=
rffi
.
cast
(
_c
.
socklen_t
,
maxlen
)
return
addr
,
addr
.
addr_p
,
addrlen_p
@
jit
.
dont_look_inside
def
accept
(
self
):
"""Wait for an incoming connection.
Return (new socket fd, client address)."""
...
...
@@ -724,6 +727,7 @@ class RSocket(object):
return
make_socket
(
fd
,
self
.
family
,
self
.
type
,
self
.
proto
,
SocketClass
=
SocketClass
)
@
jit
.
dont_look_inside
def
getpeername
(
self
):
"""Return the address of the remote endpoint."""
address
,
addr_p
,
addrlen_p
=
self
.
_addrbuf
()
...
...
@@ -738,6 +742,7 @@ class RSocket(object):
address
.
addrlen
=
rffi
.
cast
(
lltype
.
Signed
,
addrlen
)
return
address
@
jit
.
dont_look_inside
def
getsockname
(
self
):
"""Return the address of the local endpoint."""
address
,
addr_p
,
addrlen_p
=
self
.
_addrbuf
()
...
...
@@ -752,6 +757,7 @@ class RSocket(object):
address
.
addrlen
=
rffi
.
cast
(
lltype
.
Signed
,
addrlen
)
return
address
@
jit
.
dont_look_inside
def
getsockopt
(
self
,
level
,
option
,
maxlen
):
buf
=
mallocbuf
(
maxlen
)
try
:
...
...
@@ -771,6 +777,7 @@ class RSocket(object):
lltype
.
free
(
buf
,
flavor
=
'raw'
)
return
result
@
jit
.
dont_look_inside
def
getsockopt_int
(
self
,
level
,
option
):
flag_p
=
lltype
.
malloc
(
rffi
.
INTP
.
TO
,
1
,
flavor
=
'raw'
)
try
:
...
...
@@ -828,6 +835,7 @@ class RSocket(object):
rwbuffer
.
setslice
(
0
,
buf
)
return
len
(
buf
)
@
jit
.
dont_look_inside
def
recvfrom
(
self
,
buffersize
,
flags
=
0
):
"""Like recv(buffersize, flags) but also return the sender's
address."""
...
...
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