5
votes

I have a simple UDP server implemented in python:

import socket

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind(("",10005))

while True:
    data = sock.recv(1024)

I run this code on computer A. I send UDP commands from computer B in these two situations:

  1. Both A and B are connected to a router in a local network via LAN cable.
  2. Both A and B are connected to router over Wifi.

The UDP packets are received in situaltion 1 (LAN Cable) but not in situation 2 (over Wifi). In both the cases Wireshark shows the received packet on computer A. Any thoughts?

OS: Windows

The client program:

import socket 
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(char,("192.168.1.107",10005))
sock.close()

I have come close to finding the solution. Windows is dropping the UDP packets. I checked with netstat -s -p UDP command. Whenever the sending computer sends the UDP packets, the Receive Errors increase. Now I just have to figure out why the packets are being received erroneously.

Edit I have tested it on other computers. It works. I have switched of the firewall on the computer where it doesn't work but still can not figure out what is filtering out the UDP packet.

1
What is the client program, and what version of Windows are you using?rlms
Windows 7. Simplified Client Program Used: import socket sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.sendto(char,("192.168.1.107",10005)) sock.close()user3098466
Can you run netstat -r and show the output here.Shiplu Mokaddim
the output is too long for the comment.. which part of the output do you want to see?user3098466
Hey OP, you can edit your question and add the output of netstat -r to make it easier to answer. I didnt know about that when I started using Stackoverflow.Protagonist

1 Answers

1
votes

Check the trust setting on the Wifi network for the server machine. According to this article from Microsoft:

For example, a program that accepts inbound connections from the Internet (like a file sharing program) may not work in the Public profile because the Windows Firewall default setting will block all inbound connections to programs that are not on the list of allowed programs.

I believe by default Wifi networks are put in the Public profile, so it sounds like what's happening here. Since you know the packet is getting there OK (form wireshark), the most likely explanation is that the firewall refuses to deliver it for you.

The alternative would be to add python to the allowed programs list if you are perhaps not wholly trusting of the network.