mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Support default port.
This commit is contained in:
parent
bfef4a0873
commit
d3b0f38db5
1 changed files with 3 additions and 1 deletions
|
@ -39,7 +39,9 @@ TAB = '\t'
|
||||||
|
|
||||||
# Open a TCP connection to a given host and port
|
# Open a TCP connection to a given host and port
|
||||||
def open_socket(host, port):
|
def open_socket(host, port):
|
||||||
if type(port) == type(''):
|
if not port:
|
||||||
|
port = DEF_PORT
|
||||||
|
elif type(port) == type(''):
|
||||||
port = string.atoi(port)
|
port = string.atoi(port)
|
||||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
s.connect((host, port))
|
s.connect((host, port))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue