I'm using those 2 pieces of code from http://wiki.python.org/moin/UdpCommunication
The server:
import socket
UDP_IP="127.0.0.1"
UDP_PORT=5005
sock = socket.socket( socket.AF_INET, # Internet
socket.SOCK_DGRAM ) # UDP
sock.bind( (UDP_IP,UDP_PORT) )
while True:
data, addr = sock.recvfrom( 1024 ) # buffer size is 1024 bytes
print "received message:", data,"from", addr
The client:
import socket
UDP_IP="127.0.0.1"
UDP_PORT=5005
MESSAGE="Hello, World!"
print "UDP target IP:", UDP_IP
print "UDP target port:", UDP_PORT
print "message:", MESSAGE
sock = socket.socket( socket.AF_INET, # Internet
socket.SOCK_DGRAM ) # UDP
sock.sendto( MESSAGE, (UDP_IP, UDP_PORT) )
In the server, I modified the last line:
print "received message:", data,"from", addr
so it prints the address that the message was sent from. On my macbook the port seems to be some random number between 40000 or 65000 (i'm just sure it seems random).
Any idea what this could be ?