mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-01-11 18:50:34 +00:00
Update
This commit is contained in:
parent
cedc1f11e3
commit
fa7d2da973
@ -6,8 +6,10 @@
|
|||||||
# Modified by: Patrick Jentsch <p.jentsch@uni-bielefeld.de #
|
# Modified by: Patrick Jentsch <p.jentsch@uni-bielefeld.de #
|
||||||
# Modified date: Thurs Oct 10 <Uhrzeit> #
|
# Modified date: Thurs Oct 10 <Uhrzeit> #
|
||||||
# ########################################################################### #
|
# ########################################################################### #
|
||||||
|
from app import logger
|
||||||
import socket
|
import socket
|
||||||
import struct
|
import struct
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
""" 1. padding """
|
""" 1. padding """
|
||||||
@ -908,20 +910,40 @@ class Client:
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
def __recv_DATA_BYTE(self):
|
def __recv_DATA_BYTE(self):
|
||||||
byte_data = self.connection.recv(1, socket.MSG_WAITALL)
|
while True:
|
||||||
|
if (len(self.connection.recv(1, socket.MSG_PEEK)) == 1):
|
||||||
|
byte_data = self.connection.recv(1)
|
||||||
|
break
|
||||||
|
logger.warning('Waiting for data transfer to complete...')
|
||||||
|
time.sleep(0.1)
|
||||||
return struct.unpack('!B', byte_data)[0]
|
return struct.unpack('!B', byte_data)[0]
|
||||||
|
|
||||||
def __recv_DATA_BOOL(self):
|
def __recv_DATA_BOOL(self):
|
||||||
byte_data = self.connection.recv(1, socket.MSG_WAITALL)
|
while True:
|
||||||
|
if (len(self.connection.recv(1, socket.MSG_PEEK)) == 1):
|
||||||
|
byte_data = self.connection.recv(1)
|
||||||
|
break
|
||||||
|
logger.warning('Waiting for data transfer to complete...')
|
||||||
|
time.sleep(0.1)
|
||||||
return struct.unpack('!?', byte_data)[0]
|
return struct.unpack('!?', byte_data)[0]
|
||||||
|
|
||||||
def __recv_DATA_INT(self):
|
def __recv_DATA_INT(self):
|
||||||
byte_data = self.connection.recv(4, socket.MSG_WAITALL)
|
while True:
|
||||||
|
if (len(self.connection.recv(4, socket.MSG_PEEK)) == 4):
|
||||||
|
byte_data = self.connection.recv(4)
|
||||||
|
break
|
||||||
|
logger.warning('Waiting for data transfer to complete...')
|
||||||
|
time.sleep(0.1)
|
||||||
return struct.unpack('!i', byte_data)[0]
|
return struct.unpack('!i', byte_data)[0]
|
||||||
|
|
||||||
def __recv_DATA_STRING(self):
|
def __recv_DATA_STRING(self):
|
||||||
n = self.__recv_WORD()
|
n = self.__recv_WORD()
|
||||||
byte_data = self.connection.recv(n, socket.MSG_WAITALL)
|
while True:
|
||||||
|
if (len(self.connection.recv(n, socket.MSG_PEEK)) == n):
|
||||||
|
byte_data = self.connection.recv(n)
|
||||||
|
break
|
||||||
|
logger.warning('Waiting for data transfer to complete...')
|
||||||
|
time.sleep(0.1)
|
||||||
return struct.unpack('!{}s'.format(n), byte_data)[0].decode()
|
return struct.unpack('!{}s'.format(n), byte_data)[0].decode()
|
||||||
|
|
||||||
def __recv_DATA_BYTE_LIST(self):
|
def __recv_DATA_BYTE_LIST(self):
|
||||||
@ -977,7 +999,12 @@ class Client:
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
def __recv_WORD(self):
|
def __recv_WORD(self):
|
||||||
byte_data = self.connection.recv(2, socket.MSG_WAITALL)
|
while True:
|
||||||
|
if (len(self.connection.recv(2, socket.MSG_PEEK)) == 2):
|
||||||
|
byte_data = self.connection.recv(2)
|
||||||
|
break
|
||||||
|
logger.warning('Waiting for data transfer to complete...')
|
||||||
|
time.sleep(0.1)
|
||||||
return struct.unpack('!H', byte_data)[0]
|
return struct.unpack('!H', byte_data)[0]
|
||||||
|
|
||||||
def __send_BYTE(self, byte_data):
|
def __send_BYTE(self, byte_data):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user