Skip to content

Instantly share code, notes, and snippets.

@tejastank
Forked from tuxmartin/udp_ipv6_client.py
Created August 31, 2019 16:06
Show Gist options
  • Save tejastank/d2847a7c501a69671111626d7d53cba8 to your computer and use it in GitHub Desktop.
Save tejastank/d2847a7c501a69671111626d7d53cba8 to your computer and use it in GitHub Desktop.
Python UDP IPv6 client & server
import socket
UDP_IP = "::1" # localhost
UDP_PORT = 5005
MESSAGE = "Hello, World!"
print "UDP target IP:", UDP_IP
print "UDP target port:", UDP_PORT
print "message:", MESSAGE
sock = socket.socket(socket.AF_INET6, # Internet
socket.SOCK_DGRAM) # UDP
sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))
import socket
UDP_IP = "::" # = 0.0.0.0 u IPv4
UDP_PORT = 5005
sock = socket.socket(socket.AF_INET6, # 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
@tejastank
Copy link
Author

ip -6 addr
helps to see IP address

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment