Decode data of udp connection - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Networking (https://python-forum.io/forum-12.html) +--- Thread: Decode data of udp connection (/thread-5841.html) |
Decode data of udp connection - deividnastri - Oct-24-2017 Hi, i am receiving data from a UDP connection and don't know how decode this. Code where i receive the data: import socket # Set up a UDP server UDPSock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM) listen_addr = ("", 6501) UDPSock.bind(listen_addr) while True: data,addr = UDPSock.recvfrom(1024) print("Bytes: ",len(data)) print("A: ", data) print("B: ", repr(data))The data received: I try use codecs.decode, struct with no sucess.Can anyone help me? RE: Decode data of udp connection - Larz60+ - Oct-24-2017 I tried using: str.decode("utf-8", "strict")to no avail. I beleive that what you have is pure binary data, not encoded text. RE: Decode data of udp connection - deividnastri - Oct-24-2017 (Oct-24-2017, 05:04 PM)Larz60+ Wrote: I tried using: Hi Larz60, tks for ur time. I try that to, but no sucess. Will try with binary. |