Advertisement
Guest User

Untitled

a guest
May 19th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. @unwrap_spec(family=int, type=int, proto=int,
  2. w_fdobj=WrappedDefault(None))
  3. def descr_init(self, space, family=AF_INET, type=SOCK_STREAM, proto=0,
  4. w_fdobj=None):
  5. try:
  6. if not space.is_w(w_fdobj, space.w_None):
  7. if _WIN32:
  8. from rpython.rlib.rsocket import _c
  9. # it is possible to pass some bytes representing a socket
  10. # in the file descriptor object on winodws
  11. info_charptr = rffi.str2charp(w_fdobj)
  12. try:
  13. info_ptr = rffi.cast(_c.WSAPROTOCOL_INFOW, info_charptr)
  14. fd = _c.WSASocketW(_c.FROM_PROTOCOL_INFO, _c.FROM_PROTOCOL_INFO,
  15. _c.FROM_PROTOCOL_INFO, info_ptr, 0, _c.WSA_FLAG_OVERLAPPED)
  16. if fd == rsocket.INVALID_SOCKET:
  17. raise converted_error(space, rsocket.last_error())
  18. sock = RSocket(family, type, proto, fd)
  19. finally:
  20. lltype.free(info_charptr, flavor='raw')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement