python - Interpret data listen on socket -


i have code python server listen on port 5000 , interpret data.

here code :

# -*- coding: utf-8 -*- import binascii import socket   udp_ip = "" udp_port = 5000  sock = socket.socket(socket.af_inet, socket.sock_dgram) sock.bind((udp_ip, udp_port))  while true:     data, addr = sock.recvfrom(150)  

currently can't interpret data, try funtion : binascii.b2a_uu() without result. data in frame have same size, , coded on 32 bits.

thank help.

nicolas.

edit : use python 2.7

solution : after recvfrom, store data on tab. each information coded on 32 bits, read table 4 bytes per 4 bytes , use function : struct.unpack(">l", data[0:4])[0] retrive informations. thid allow have ip address on long format


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -