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

Skip to content

Commit a8d30d5

Browse files
committed
update demo scripts to use addr tuples for bind and connect
closes bug #111928
1 parent 239f836 commit a8d30d5

6 files changed

Lines changed: 9 additions & 9 deletions

File tree

Demo/sockets/finger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#
2424
def finger(host, args):
2525
s = socket(AF_INET, SOCK_STREAM)
26-
s.connect(host, FINGER_PORT)
26+
s.connect((host, FINGER_PORT))
2727
s.send(args + '\n')
2828
while 1:
2929
buf = s.recv(1024)

Demo/sockets/ftp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def control(hostname):
4848
# Create control connection
4949
#
5050
s = socket(AF_INET, SOCK_STREAM)
51-
s.connect(hostname, FTP_PORT)
51+
s.connect((hostname, FTP_PORT))
5252
f = s.makefile('r') # Reading the replies is easier from a file...
5353
#
5454
# Control loop
@@ -79,7 +79,7 @@ def newdataport(s, f):
7979
port = nextport + FTP_DATA_PORT
8080
nextport = (nextport+1) % 16
8181
r = socket(AF_INET, SOCK_STREAM)
82-
r.bind(gethostbyname(gethostname()), port)
82+
r.bind((gethostbyname(gethostname()), port))
8383
r.listen(1)
8484
sendportcmd(s, f, port)
8585
return r

Demo/sockets/rpythond.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def main():
1919
else:
2020
port = PORT
2121
s = socket(AF_INET, SOCK_STREAM)
22-
s.bind('', port)
22+
s.bind(('', port))
2323
s.listen(1)
2424
while 1:
2525
conn, (remotehost, remoteport) = s.accept()

Demo/sockets/telnet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def main():
5151
s = socket(AF_INET, SOCK_STREAM)
5252
#
5353
try:
54-
s.connect(host, port)
54+
s.connect((host, port))
5555
except error, msg:
5656
sys.stderr.write('connect failed: ' + `msg` + '\n')
5757
sys.exit(1)

Demo/sockets/throughput.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def server():
4444
else:
4545
port = MY_PORT
4646
s = socket(AF_INET, SOCK_STREAM)
47-
s.bind('', port)
47+
s.bind(('', port))
4848
s.listen(1)
4949
print 'Server ready...'
5050
while 1:
@@ -72,7 +72,7 @@ def client():
7272
t1 = time.time()
7373
s = socket(AF_INET, SOCK_STREAM)
7474
t2 = time.time()
75-
s.connect(host, port)
75+
s.connect((host, port))
7676
t3 = time.time()
7777
i = 0
7878
while i < count:

Demo/sockets/udpecho.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def server():
3333
else:
3434
port = ECHO_PORT
3535
s = socket(AF_INET, SOCK_DGRAM)
36-
s.bind('', port)
36+
s.bind(('', port))
3737
print 'udp echo server ready'
3838
while 1:
3939
data, addr = s.recvfrom(BUFSIZE)
@@ -50,7 +50,7 @@ def client():
5050
port = ECHO_PORT
5151
addr = host, port
5252
s = socket(AF_INET, SOCK_DGRAM)
53-
s.bind('', 0)
53+
s.bind(('', 0))
5454
print 'udp echo client ready, reading stdin'
5555
while 1:
5656
line = sys.stdin.readline()

0 commit comments

Comments
 (0)