-
-
Save jeffgeiger/0b9d1f9c62e9647fed7bbdca18e4ada1 to your computer and use it in GitHub Desktop.
Quick 'n' dirty Python script to listen on a port and do nothing with the connection, simulating a server that allows you to connect but does not reply.
This file contains 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/python | |
import socket | |
import sys | |
if (len(sys.argv) != 2 or not sys.argv[1].isdigit()): | |
print 'Usage: listen <port>', | |
exit() | |
p = int(sys.argv[1]) | |
l = [] | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.bind(('', p)) | |
s.listen(1) | |
while 1: | |
(c, a) = s.accept() | |
l.append(c) | |
print '%d: connection from %s' % (len(l), a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment