1

My program doesn't receive any packets (on UDP, Windows 10), but when I sniff the data on Wireshark I can see that the data is indeed sent. I know that it doesn't have anything to do with my local network because when I switch to a hotspot it still doesn't work.

Another thing is that the program receives the data for my friends who work with me on the same project, but for me, even if I'm using the same computer for the client and server it doesn't work.

I even tried to enable Promiscuous in the program via the os module after binding the socket by adding these lines:

if os.name == “nt”:
    s.ioctl(socket.SIO_RCVALL, socket.RCVALL_ON)

but all I got was

Traceback (most recent call last):
  File "C:/Users/roeym/PycharmProjects/client game/tank_trouble_dynamic_map.py", line 5, in <module>
    import tank_client
  File "C:\Users\roeym\PycharmProjects\client game\tank_client.py", line 13, in <module>
    s.ioctl(socket.SIO_RCVALL, socket.RCVALL_ON)
OSError: [WinError 10022] An invalid argument was supplied

Can you please help me figure out why my program doesn't receive the data?

This is how I set the socket up:

ip = socket.gethostbyname(socket.gethostname())
port = 8888

s = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM)
s.bind((ip, port))

print(f"[!][!]  Server is up, running on {ip}, port- {port}  [!][!]")

and this is how I receive packets:

while run:
    data, ip = s.recvfrom(bufferSize)
    data = str(data)
    data = data[2:]
    data = data[:-1]
    if data == "":
        continue

    print(data)
furas
  • 134,197
  • 12
  • 106
  • 148
Roey_MR
  • 23
  • 5
  • aalways put full error message (starting at word "Traceback") in question (not in comments) as text (not screenshot, not link to external portal). There are other useful information. – furas May 06 '22 at 13:54
  • better show minimal working code so we could copy and run it to see problem. – furas May 06 '22 at 13:55
  • added full traceback. – Roey_MR May 06 '22 at 17:18
  • error shows problem in file `tank_client.py` but you show code for server. – furas May 06 '22 at 19:30
  • in server you can use `0.0.0.0` as IP and it will listen on all Network Cards in computer. Maybe your server was listening on one Network Card but client send using other network card. Maybe better show minimal working code so we could copy and run it to see problem. – furas May 06 '22 at 19:32
  • My bad, I found out that I pass the server ip to a function that sends a login packet to the server. It turned out that the server ip that I passed was wrong all along. Thank you for your help. – Roey_MR May 07 '22 at 16:20

0 Answers0