Skip to content

Instantly share code, notes, and snippets.

@vo
Last active April 20, 2019 05:00
Show Gist options
  • Save vo/44392196602762f8373b8f9cedb459b5 to your computer and use it in GitHub Desktop.
Save vo/44392196602762f8373b8f9cedb459b5 to your computer and use it in GitHub Desktop.
send and recv udp python
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind(('0.0.0.0', 5005))
while True:
data, addr = sock.recvfrom(65536)
print("received: %d" % len(data))
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
for i in range(65507+1):
print('size = %d' % i)
sock.sendto('*' * i, ('127.0.0.1', 5005))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment