コード例 #1
0
 def READ(self, size):
     from pypy.rlib._rsocket_rffi import socketrecv, geterrno
     with rffi.scoped_alloc_buffer(size) as buf:
         length = socketrecv(self.fd, buf.raw, buf.size, 0)
         if length < 0:
             raise WindowsError(geterrno(), "recv")
         return buf.str(length)
コード例 #2
0
ファイル: interp_connection.py プロジェクト: Debug-Orz/Sypy
 def READ(self, size):
     from pypy.rlib._rsocket_rffi import socketrecv, geterrno
     with rffi.scoped_alloc_buffer(size) as buf:
         length = socketrecv(self.fd, buf.raw, buf.size, 0)
         if length < 0:
             raise WindowsError(geterrno(), "recv")
         return buf.str(length)
コード例 #3
0
ファイル: rsocket.py プロジェクト: alkorzt/pypy
 def recv(self, buffersize, flags=0):
     """Receive up to buffersize bytes from the socket.  For the optional
     flags argument, see the Unix manual.  When no data is available, block
     until at least one byte is available or until the remote end is closed.
     When the remote end is closed and all data is read, return the empty
     string."""
     timeout = self._select(False)
     if timeout == 1:
         raise SocketTimeout
     elif timeout == 0:
         raw_buf, gc_buf = rffi.alloc_buffer(buffersize)
         try:
             read_bytes = _c.socketrecv(self.fd, raw_buf, buffersize, flags)
             if read_bytes >= 0:
                 return rffi.str_from_buffer(raw_buf, gc_buf, buffersize, read_bytes)
         finally:
             rffi.keep_buffer_alive_until_here(raw_buf, gc_buf)
     raise self.error_handler()
コード例 #4
0
ファイル: rsocket.py プロジェクト: antoine1fr/pygirl
 def recv(self, buffersize, flags=0):
     """Receive up to buffersize bytes from the socket.  For the optional
     flags argument, see the Unix manual.  When no data is available, block
     until at least one byte is available or until the remote end is closed.
     When the remote end is closed and all data is read, return the empty
     string."""
     timeout = self._select(False)
     if timeout == 1:
         raise SocketTimeout
     elif timeout == 0:
         buf = mallocbuf(buffersize)
         try:
             read_bytes = _c.socketrecv(self.fd, buf, buffersize, flags)
             if read_bytes >= 0:
                 assert read_bytes <= buffersize
                 return ''.join([buf[i] for i in range(read_bytes)])
         finally:
             lltype.free(buf, flavor='raw')
     raise self.error_handler()
コード例 #5
0
 def recv(self, buffersize, flags=0):
     """Receive up to buffersize bytes from the socket.  For the optional
     flags argument, see the Unix manual.  When no data is available, block
     until at least one byte is available or until the remote end is closed.
     When the remote end is closed and all data is read, return the empty
     string."""
     timeout = self._select(False)
     if timeout == 1:
         raise SocketTimeout
     elif timeout == 0:
         buf = mallocbuf(buffersize)
         try:
             read_bytes = _c.socketrecv(self.fd, buf, buffersize, flags)
             if read_bytes >= 0:
                 assert read_bytes <= buffersize
                 return ''.join([buf[i] for i in range(read_bytes)])
         finally:
             lltype.free(buf, flavor='raw')
     raise self.error_handler()
コード例 #6
0
 def recv(self, buffersize, flags=0):
     """Receive up to buffersize bytes from the socket.  For the optional
     flags argument, see the Unix manual.  When no data is available, block
     until at least one byte is available or until the remote end is closed.
     When the remote end is closed and all data is read, return the empty
     string."""
     timeout = self._select(False)
     if timeout == 1:
         raise SocketTimeout
     elif timeout == 0:
         raw_buf, gc_buf = rffi.alloc_buffer(buffersize)
         try:
             read_bytes = _c.socketrecv(self.fd, raw_buf, buffersize, flags)
             if read_bytes >= 0:
                 return rffi.str_from_buffer(raw_buf, gc_buf, buffersize,
                                             read_bytes)
         finally:
             rffi.keep_buffer_alive_until_here(raw_buf, gc_buf)
     raise self.error_handler()