Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @unwrap_spec(family=int, type=int, proto=int,
- w_fdobj=WrappedDefault(None))
- def descr_init(self, space, family=AF_INET, type=SOCK_STREAM, proto=0,
- w_fdobj=None):
- try:
- if not space.is_w(w_fdobj, space.w_None):
- if _WIN32:
- from rpython.rlib.rsocket import _c
- # it is possible to pass some bytes representing a socket
- # in the file descriptor object on winodws
- info_charptr = rffi.str2charp(w_fdobj)
- try:
- info_ptr = rffi.cast(_c.WSAPROTOCOL_INFOW, info_charptr)
- fd = _c.WSASocketW(_c.FROM_PROTOCOL_INFO, _c.FROM_PROTOCOL_INFO,
- _c.FROM_PROTOCOL_INFO, info_ptr, 0, _c.WSA_FLAG_OVERLAPPED)
- if fd == rsocket.INVALID_SOCKET:
- raise converted_error(space, rsocket.last_error())
- sock = RSocket(family, type, proto, fd)
- finally:
- lltype.free(info_charptr, flavor='raw')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement