Created
February 19, 2013 02:29
-
-
Save redspider/4982602 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
s.sendto('PING', ('127.0.0.1',540)) | |
data, addr = s.recvfrom(1024) | |
print data, addr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
s.bind(('0.0.0.0', 540)) | |
print "Socket ready" | |
while True: | |
data, addr = s.recvfrom(1024) | |
print "Received presumed ping from ",addr | |
s.sendto('PONG', addr) | |
print "Sent pong" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment