Skip to content

Instantly share code, notes, and snippets.

@wyyqyl
Created October 28, 2014 01:42
Show Gist options
  • Select an option

  • Save wyyqyl/2d6cf6079f8d6cadb4c8 to your computer and use it in GitHub Desktop.

Select an option

Save wyyqyl/2d6cf6079f8d6cadb4c8 to your computer and use it in GitHub Desktop.
port occupation demo
import socket
HOST = '127.0.0.1'
try:
s1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s1.bind((HOST, 13748))
s2 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s2.bind((HOST, 15428))
s3 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s3.bind((HOST, 27382))
s4 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s4.bind((HOST, 36874))
s5 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s5.bind((HOST, 45242))
except socket.error as msg:
print msg
input('123')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment