mirror of
https://github.com/bkerler/edl.git
synced 2024-11-14 19:14:58 -05:00
7f14a79019
Remove Some useless Codes Replace '2018-2023' to '2018-2024'
28 lines
925 B
Python
Executable file
28 lines
925 B
Python
Executable file
import socket
|
|
from binascii import hexlify
|
|
|
|
|
|
class tcpclient:
|
|
def __init__(self, port):
|
|
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
server_address = ("localhost", port)
|
|
print("connecting to %s port %s" % server_address)
|
|
self.sock.connect(server_address)
|
|
|
|
def sendcommands(self, commands):
|
|
try:
|
|
for command in commands:
|
|
self.sock.sendall(bytes(command, 'utf-8'))
|
|
data = ""
|
|
while "<ACK>" not in data and "<NAK>" not in data:
|
|
tmp = self.sock.recv(4096)
|
|
if tmp == b"":
|
|
continue
|
|
try:
|
|
data += tmp.decode('utf-8')
|
|
except:
|
|
data += hexlify(tmp)
|
|
print(data)
|
|
finally:
|
|
print("closing socket")
|
|
self.sock.close()
|