Created
January 24, 2016 00:17
-
-
Save radiovisual/308ebe5608d07511797e to your computer and use it in GitHub Desktop.
Bind a useless process to any port (useful for testing)
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 | |
import sys | |
# Create a TCP/IP socket | |
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
port = sys.argv[1] | |
# Bind the socket to the port | |
server_address = ('localhost', int(port)) | |
print sys.stderr, 'starting up on %s port %s' % server_address | |
sock.bind(server_address) | |
raw_input("click any key to shutdown...") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run the file with this command:
python bindToUDP.py <port>