I used python twisted and receiving data properly only sometimes I am receiving data with hex dat like this:
b'\x05\x00\x00\x00\xe9\x00{ "iMsgType": 5, "l_szSessionId": "Ranjith;11961"}\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
Could anyone please give me solution? Earlier I used socket programming but missing data, but twisted is good I am getting this data.
Client code is in c sending json
string through socket.
Please find the below python code
from twisted.internet import protocol, reactor
class EchoProtocol(protocol.Protocol):
def dataReceived(self, data):
self.transport.write(data) # Echo back the received data
class EchoFactory(protocol.Factory):
def buildProtocol(self, addr):
return EchoProtocol()
if __name__ == "__main__":
port = 12345 # Specify the port you want to listen on
reactor.listenTCP(port, EchoFactory())
print(f"Listening on port {port}")
reactor.run()