My Windows7 UDP server with the code below from wiki.python.org is not working.
I am sending a UDP packet from an Arduino , but nothing is being received. I think the problem is that TCPview says the socket exists, but it does not say "listening". I'm not certain that it should say "listening" like most other ports, but I'm guessing it should.
I am a new Python user, but I have a lot of networking experience and I think that have configured my routers and firewalls correctly.
Any ideas?
-----------------------------------------------code ----------------------
import socket
UDP_IP = "0.0.0.0"
UDP_PORT = 9000
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
Are you sure the Arduino is set up correctly, see :
https://www.arduino.cc/en/Reference/Ethernet
To see if you are connected on the windows machine, open a command terminal with administrative permissions and type
netstat -a
and/or
netstat -b
, type
netstat /?
for definitions of options.
If you have a firewall, try disabling it temporarily for testing.
(Apr-26-2017, 07:57 PM)sparkz_alot Wrote: [ -> ]Are you sure the Arduino is set up correctly, see : https://www.arduino.cc/en/Reference/Ethernet
To see if you are connected on the windows machine, open a command terminal with administrative permissions and type
netstat -a
and/or netstat -b
, type netstat /?
for definitions of options.
If you have a firewall, try disabling it temporarily for testing.
The two netstat commands do not show my udp port(9000). But the two netstat commands only apply to those ports with connections or listening. Again, I don't think the python port is listening.
TCPview is a Microsoft utility that gives more detail and that shows the port is not listening and the associated process is pythonw.exe.
I already disabled my firewall and virus protection.
I'm pretty sure the Ardurino is setup correctly as I have used the same setup to other UDP servers.
Thanks
Did you try to connect to python server from your pc? I have tried your code (but only on linux), and with python client (from same page on wiki.python.org) it worked without problem. Unfortunately i have no experience with arduino.
(Apr-26-2017, 08:47 PM)zivoni Wrote: [ -> ]Did you try to connect to python server from your pc? I have tried your code (but only on linux), and with python client (from same page on wiki.python.org) it worked without problem. Unfortunately i have no experience with arduino.
Great idea.....I tried it and it worked. That is, I was able to send from the python client and it was received by the python server.
But wait, all of a sudden the arduino client is also working....
And the UDP server port(9000) still doesn't say "listening".
Time to reboot everything and see what happens.
I was hung up that the UDP port wasn't listening, now I see that apparently doesn't matter and I can pursue other avenues if there is still a problem after reboot.
Thanks for all the help, you put me back on track.
Frank
Probably an unseated cable
You should start checking the cables.
Then check the router. Whether port 9000 is set in the NAT settings.
Next, you can see if you are able to connect to the server on address 127.0.0.1:9000. Connecting from the same machine.