def odbierz_dane(socket): rozmiar = int(socket.recv(1024)) if rozmiar != 0: socket.send("1") dane = socket.recv(rozmiar) return dane else: socket.send("0") print "Problem z odbiorem danych!"
def recv(self, buflen=1024, flags=0): self._checkClosed() if self._sslobj: if flags != 0: raise ValueError("non-zero flags not allowed in calls to recv() on %s" % self.__class__) return self.read(buflen) else: return socket.recv(self, buflen, flags)
def recv(self, buflen=1024, flags=0): if self._sslobj: if flags != 0: raise ValueError("non-zero flags not allowed in calls to recv() on %s" % self.__class__) # QQQ Shouldn't we wrap the SSL_WANT_READ errors as socket.timeout errors to match socket.recv's behavior? return self.read(buflen) else: return socket.recv(self, buflen, flags)
def wyslij_dane(socket, dane): dlugosc = str(len(dane)) socket.send(dlugosc) ack = socket.recv(3) ack = int(ack) if ack == 1: socket.send(dane) else: print "Mamy problem - serwer nie odpowiada na wiadomosc o dlugosci danych!"
def recv(self, buflen=1024, flags=0): if self._sslobj: if flags != 0: raise ValueError( "non-zero flags not allowed in calls to recv() on %s" % self.__class__) # QQQ Shouldn't we wrap the SSL_WANT_READ errors as socket.timeout errors to match socket.recv's behavior? return self.read(buflen) else: return socket.recv(self, buflen, flags)
def recv(self, buflen=1024, flags=0): self._checkClosed() if self._sslobj: if flags != 0: raise ValueError( "non-zero flags not allowed in calls to recv() on %s" % self.__class__) return self.read(buflen) else: return socket.recv(self, buflen, flags)
def recv(self, buflen=1024, flags=0): self._checkClosed() if self._sslobj: if flags != 0: raise ValueError( "non-zero flags not allowed in calls to recv() on %s" % self.__class__) if buflen == 0: # https://github.com/python/cpython/commit/00915577dd84ba75016400793bf547666e6b29b5 # Python #23804 return b'' return self.read(buflen) return socket.recv(self, buflen, flags)
"non-zero flags not allowed in calls to recv() on %s" % self.__class__) while True: try: return self.read(buflen) except SSLError, x: if x.args[0] == SSL_ERROR_WANT_READ: sys.exc_clear() if self.timeout == 0.0: raise timeout(str(x)) wait_read(self.fileno(), timeout=self.timeout) continue else: raise else: return socket.recv(self, buflen, flags) def recv_into(self, buffer, nbytes=None, flags=0): if buffer and (nbytes is None): nbytes = len(buffer) elif nbytes is None: nbytes = 1024 if self._sslobj: if flags != 0: raise ValueError( "non-zero flags not allowed in calls to recv_into() on %s" % self.__class__) while True: try: tmp_buffer = self.read(nbytes) v = len(tmp_buffer)