Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4550b00

Browse files
committed
Fix bit rot: use sock.connect((host, port)) and allow 2nd cmd line
arg.
1 parent de77bc5 commit 4550b00

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Demo/threads/telnet.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
WILL = chr(251)
2929

3030
def main():
31-
if len(sys.argv) != 2:
32-
sys.stderr.write('usage: telnet hostname\n')
31+
if len(sys.argv) < 2:
32+
sys.stderr.write('usage: telnet hostname [port]\n')
3333
sys.exit(2)
3434
host = sys.argv[1]
3535
try:
@@ -55,7 +55,7 @@ def main():
5555
s = socket(AF_INET, SOCK_STREAM)
5656
#
5757
try:
58-
s.connect(host, port)
58+
s.connect((host, port))
5959
except error, msg:
6060
sys.stderr.write('connect failed: ' + `msg` + '\n')
6161
sys.exit(1)

0 commit comments

Comments
 (0)