Does the Digi WR41/21 python support UDP socket ?


I have a Digi WR21 and a WR41.
I’d like to get information from a sensor device using a SNMP python script on WR21/WR41.
I made rebuilding the pysnmp module, put it into WR21/41, and execute the script.
But, it didn’t work well, the UDP connection is timed out.
It woks well on the PC python.

So, I tried to make simple UDP communication scripts (see below).
It does not connect (no response) between WR21/41 and PC. Also change the server and the client. the WR21/41 settings are factory default settings.
It connect well between two PCs.

How can I connect UDP socket using the WR21/41 python script and a PC/device?

Thank you.

[server script:]
import socket

host = ‘’
port = 50000
bufsize = 80

print “srvr: socket”
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
print “srvr: bind…”
sock.bind((host, port))
print “srvr: wait for udp senders and receivers”
clients = []
while True:
msg, addr = sock.recvfrom(bufsize)
ip, port = addr
msg = “[%s][%s] %s” % (ip, port, msg)
print "srvr: deliver " + msg
for addr in clients:
sock.sendto(msg, addr)
except socket.error, e:
if str(e) != ‘timed out’:
print ‘Error: %s’ % e

[client script:]
import socket

host = ‘’
port = 50000
bufsize = 80

print “recv: socket”
sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
print “recv: connect”
print “recv: wait for messages”
sock.send(“new connect”)
while True:
print sock.recv(bufsize)
except socket.error, e:
if str(e) != “timed out”:
print ‘Error: %s’ % e

[correct response with two PCs : server]
srvr: socket
srvr: bind…
srvr: wait for udp senders and receivers
srvr: deliver [][61442] new connect

[correct response with two PCs : client]
recv: socket
recv: connect
recv: wait for messages
[][61442] new connect

Hello, if you’re expecting connections from another outside device, then your server socket code should not have a host listed. Leave this blank, which means connect to any incoming socket socket on any of the interfaces. If you’re usign sockets to communicate between other threads of python scripts on the same device, then you can even use ‘localhost’ which will accept any socket connection from the device itself.

I would try in your socket code, changing

host = ‘’

to simply host = ‘’