Reputation: 1211
I have the following short code:
import socket
from sys import *
host = "10.10.10.10"
port = 7142
buf = 1024
tcpSock = socket.socket()
tcpSock.settimeout(100)
tcpSock.connect((host,port))
## Send message
data ='\x01\x30\x41\x30\x41\x30\x36\x02\x30\x31\x44\x36\x03\x74\x0d'
if(tcpSock.send(data)):
print "Sending message:",data
data = tcpSock.recv(4096)
tcpSock.close()
print "Received message:", data
#print "Received message:", data.strip().decode("hex")
the output been:
Sending message: ☺0A0A06☻01D6♥t
Received message: ☺00AB12☻0200D60000040001♥t
Where I am stuck on is how to decode the "received message" back from the server to HEX characters
Thanks Alexis
Upvotes: 3
Views: 8637
Reputation: 1895
Please try this code
import binascii
mytext='☺00AB12☻0200D60000040001♥t'
print binascii.hexlify(mytext)
I've received this output
3f3030414231323f303230304436303030303034303030313f74
Upvotes: 6