示例#1
0
文件: rsocket.py 项目: alkorzt/pypy
 def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0):
     """Create a new socket."""
     fd = _c.socket(family, type, proto)
     if _c.invalid_socket(fd):
         raise self.error_handler()
     # PLAT RISCOS
     self.fd = fd
     self.family = family
     self.type = type
     self.proto = proto
     self.timeout = defaults.timeout
示例#2
0
 def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0):
     """Create a new socket."""
     fd = _c.socket(family, type, proto)
     if _c.invalid_socket(fd):
         raise self.error_handler()
     # PLAT RISCOS
     self.fd = fd
     self.family = family
     self.type = type
     self.proto = proto
     self.timeout = defaults.timeout
示例#3
0
文件: rsocket.py 项目: alkorzt/pypy
 def accept(self, SocketClass=None):
     """Wait for an incoming connection.
     Return (new socket object, client address)."""
     if SocketClass is None:
         SocketClass = RSocket
     if self._select(False) == 1:
         raise SocketTimeout
     address, addr_p, addrlen_p = self._addrbuf()
     try:
         newfd = _c.socketaccept(self.fd, addr_p, addrlen_p)
         addrlen = addrlen_p[0]
     finally:
         lltype.free(addrlen_p, flavor='raw')
         address.unlock()
     if _c.invalid_socket(newfd):
         raise self.error_handler()
     address.addrlen = rffi.cast(lltype.Signed, addrlen)
     sock = make_socket(newfd, self.family, self.type, self.proto,
                        SocketClass)
     return (sock, address)
示例#4
0
 def accept(self, SocketClass=None):
     """Wait for an incoming connection.
     Return (new socket object, client address)."""
     if SocketClass is None:
         SocketClass = RSocket
     if self._select(False) == 1:
         raise SocketTimeout
     address, addr_p, addrlen_p = self._addrbuf()
     try:
         newfd = _c.socketaccept(self.fd, addr_p, addrlen_p)
         addrlen = addrlen_p[0]
     finally:
         lltype.free(addrlen_p, flavor='raw')
         address.unlock()
     if _c.invalid_socket(newfd):
         raise self.error_handler()
     address.addrlen = rffi.cast(lltype.Signed, addrlen)
     sock = make_socket(newfd, self.family, self.type, self.proto,
                        SocketClass)
     return (sock, address)
示例#5
0
文件: rsocket.py 项目: alkorzt/pypy
 def fileno(self):
     fd = self.fd
     if _c.invalid_socket(fd):
         raise RSocketError("socket already closed")
     return fd
示例#6
0
 def fileno(self):
     fd = self.fd
     if _c.invalid_socket(fd):
         raise RSocketError("socket already closed")
     return fd