Python Forum

Full Version: Udp socket
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello iam new to the python language, Iam trying to send a udp packet on my machine and use wireshark to see the data come through so far i have not seen any data inbound or outbound on my machine.Below is the code iam using and iam also using python version 2.7.15 just want to make sure my code is good before i start looking elsewhere for the problem.Thanks

import socket

UDP_IP = "127.0.0.1"
UDP_PORT = 5005
MESSAGE = "Hello, World!"


sock = socket.socket(socket.AF_INET, # Internet
                     socket.SOCK_DGRAM) # UDP
print "init...."
while True:
    sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))
    print "sent data"
is wireshark capturing any network activity at all? It can be tricky to set up properly.
Make sure you are connected to port 5005 (wireshark)
Yes it does capture other data, im just using a display filter udp.port == 5005.Also i forgot to mention i have ran the code with both my anti virus and windows defender disabled and still no data on port 5005.I've only used wireshark a handful of times so maybe something isnt configured correctly in it.

Well figured something out if i change the ip in the python script from 127.0.0.1 to 236.4.0.5 and use port 29999 i see my hello world show up in the data through wireshark.I dont know exactly what is causing it.
well 127.0.0.1 is your computer.
And although I used to know my way around networking protocol, it's been a long time.
Not sure why that would make a difference