Skip to content

Instantly share code, notes, and snippets.

@vik-y
Created July 31, 2015 20:06
Show Gist options
  • Save vik-y/ab023a0c439e6caf0e68 to your computer and use it in GitHub Desktop.
Save vik-y/ab023a0c439e6caf0e68 to your computer and use it in GitHub Desktop.
from socket import *
s=socket(AF_INET, SOCK_DGRAM)
s.bind(('',12345))
m=s.recvfrom(1024)
print m[0]
'''
A simple implementation of broadcast of packets in python
send.py -> How packets are broadcasted
receive.py -> How broadcasts are received
'''
from socket import *
s=socket(AF_INET, SOCK_DGRAM)
s.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)
s.sendto('this is testing',('255.255.255.255',12345))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment