import socket # Import socket modular
import struct
s = socket.socket() # Create socket
host = '169.254.68.37' # host IP
port = 2112
s.connect((host,port)) # Active initialization TCP Server connection
# send_data = input(' Please input the data to be sent ') # Prompt the user to enter data
a = [0x02 , 0x73 , 0x45 , 0x4E , 0x20 , 0x4C , 0x4D , 0x44 , 0x73 , 0x63 ,
0x61 , 0x6E , 0x64 , 0x61 , 0x74 , 0x61 , 0x20 , 0x31 , 0x03] # Your hex command array
data = struct.pack("%dB" % (len(a)), *a) # adopt struct Convert to sent hexadecimal string
s.send(data) # send out TCP data
print(" Sent ready to receive ")
# Accept the data sent by the other party , The greatest acceptance 1024 byte
recvData = s.recv(1024).decode()
print(' The received data is :', recvData)
# Close socket
s.close()