1402 Private method to handle data from the client. |
1402 Private method to handle data from the client. |
1403 |
1403 |
1404 @param sock reference to the socket to read data from |
1404 @param sock reference to the socket to read data from |
1405 @type QTcpSocket |
1405 @type QTcpSocket |
1406 """ |
1406 """ |
|
1407 headerSize = struct.calcsize(b"!II") |
|
1408 |
1407 while sock and sock.bytesAvailable(): |
1409 while sock and sock.bytesAvailable(): |
1408 header = sock.read(struct.calcsize(b"!II")) |
1410 now = time.monotonic() |
|
1411 while sock.bytesAvailable() < headerSize: |
|
1412 sock.waitForReadyRead(50) |
|
1413 if time.monotonic() - now > 2.0: # 2 seconds timeout |
|
1414 return |
|
1415 header = sock.read(headerSize) |
1409 length, datahash = struct.unpack(b"!II", header) |
1416 length, datahash = struct.unpack(b"!II", header) |
1410 |
1417 |
1411 data = bytearray() |
1418 data = bytearray() |
1412 now = time.monotonic() |
1419 now = time.monotonic() |
1413 while len(data) < length: |
1420 while len(data) < length: |