Created
February 6, 2018 09:47
-
-
Save laginha87/2e965e465577875e4da758176679bdb1 to your computer and use it in GitHub Desktop.
dog_sniff.py
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
#!/usr/bin/env python | |
import socket | |
import sys | |
# Create a TCP/IP socket | |
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
# Bind the socket to the port | |
server_address = ('localhost', 8125) | |
print >>sys.stderr, 'starting up on %s port %s' % server_address | |
sock.bind(server_address) | |
while True: | |
print >>sys.stderr, '\nwaiting to receive message' | |
data, address = sock.recvfrom(4096) | |
print >>sys.stderr, 'received %s bytes from %s' % (len(data), address) | |
print >>sys.stderr, data | |
if data: | |
sent = sock.sendto(data, address) | |
print >>sys.stderr, 'sent %s bytes back to %s' % (sent, address) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment