Does the Digi WR41/21 python support UDP socket ?

Hello,

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 pysnmp.zip rebuilding the pysnmp module, put it into WR21/41, and execute the snmpwalk.py 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: udpsrvr.py]
import socket

host = ‘192.168.1.1’
port = 50000
bufsize = 80

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

[client script: udprcvr.py]
import socket

host = ‘192.168.1.1’
port = 50000
bufsize = 80

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

[correct response with two PCs : server]
PC>python udpsrvr.py
srvr: socket
srvr: bind…
srvr: wait for udp senders and receivers
srvr: deliver [192.168.1.2][61442] new connect

[correct response with two PCs : client]
PC>python udprcvr.py
recv: socket
recv: connect
recv: wait for messages
[192.168.1.2][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 = ‘192.168.1.1’

to simply host = ‘’

NF