Python Forum
Simple UDP server not receiving
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple UDP server not receiving
#1
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
Reply
#2
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.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#3
(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
Reply
#4
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.
Reply
#5
(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
Reply
#6
Probably an unseated cable
Reply
#7
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.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Receiving this error in my "response" and causes script to return wrong status cubangt 18 2,026 Aug-13-2023, 12:16 AM
Last Post: cubangt
  SMA (simple moving avg) Not receiving Data (stock prices). gdbengo 2 1,435 Jul-31-2022, 08:20 PM
Last Post: paulyan
  Receiving snmp traps with more than one Community String ilknurg 0 2,196 Jan-19-2022, 09:02 AM
Last Post: ilknurg
  How to take the tar backup files form remote server to local server sivareddy 0 1,891 Jul-14-2021, 01:32 PM
Last Post: sivareddy
  [Selenium]Timed out receiving message from renderer: 10.000 wood_6636 0 2,620 Jun-26-2020, 08:59 AM
Last Post: wood_6636
  Receiving XML exception from nmap.scan() results. PythonNmap 4 4,080 Jan-21-2020, 04:41 AM
Last Post: PythonNmap
  Trying to use python-nmap but receiving however python2 or 3 can't find PortScanner. PythonNmap 21 10,806 Jan-19-2020, 07:54 PM
Last Post: PythonNmap
  First Byte of a string is missing while receiving data over TCP Socket shahrukh1987 3 4,218 Nov-20-2019, 10:34 AM
Last Post: shahrukh1987
  Not receiving serial data from arduino dinoel_cool 4 3,670 Aug-26-2018, 06:16 PM
Last Post: j.crater
  Receiving large data stream using Pyserial trampas 1 4,234 Mar-09-2017, 03:32 AM
Last Post: Analyser

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020