Ejemplo n.º 1
0
 def READ(self, size):
     from rpython.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)
Ejemplo n.º 2
0
 def READ(self, size):
     from rpython.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)
Ejemplo n.º 3
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:
         with rffi.scoped_alloc_buffer(buffersize) as buf:
             read_bytes = _c.socketrecv(self.fd, rffi.cast(rffi.VOIDP, buf.raw), buffersize, flags)
             if read_bytes >= 0:
                 return buf.str(read_bytes)
     raise self.error_handler()
Ejemplo n.º 4
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:
         with rffi.scoped_alloc_buffer(buffersize) as buf:
             read_bytes = _c.socketrecv(self.fd,
                                        rffi.cast(rffi.VOIDP, buf.raw),
                                        buffersize, flags)
             if read_bytes >= 0:
                 return buf.str(read_bytes)
     raise self.error_handler()
Ejemplo n.º 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:
         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()
Ejemplo n.º 6
0
def multiprocessing_recv(space, handle, buffersize):
    with rffi.scoped_alloc_buffer(buffersize) as buf:
        read_bytes = socketrecv(handle, buf.raw, buffersize, 0)
        if read_bytes >= 0:
            return space.newtext(buf.str(read_bytes))
    raise getWindowsError(space)