#
def finger(host, args):
s = socket(AF_INET, SOCK_STREAM)
- s.connect(host, FINGER_PORT)
+ s.connect((host, FINGER_PORT))
s.send(args + '\n')
while 1:
buf = s.recv(1024)
# Create control connection
#
s = socket(AF_INET, SOCK_STREAM)
- s.connect(hostname, FTP_PORT)
+ s.connect((hostname, FTP_PORT))
f = s.makefile('r') # Reading the replies is easier from a file...
#
# Control loop
port = nextport + FTP_DATA_PORT
nextport = (nextport+1) % 16
r = socket(AF_INET, SOCK_STREAM)
- r.bind(gethostbyname(gethostname()), port)
+ r.bind((gethostbyname(gethostname()), port))
r.listen(1)
sendportcmd(s, f, port)
return r
else:
port = PORT
s = socket(AF_INET, SOCK_STREAM)
- s.bind('', port)
+ s.bind(('', port))
s.listen(1)
while 1:
conn, (remotehost, remoteport) = s.accept()
s = socket(AF_INET, SOCK_STREAM)
#
try:
- s.connect(host, port)
+ s.connect((host, port))
except error, msg:
sys.stderr.write('connect failed: ' + `msg` + '\n')
sys.exit(1)
else:
port = MY_PORT
s = socket(AF_INET, SOCK_STREAM)
- s.bind('', port)
+ s.bind(('', port))
s.listen(1)
print 'Server ready...'
while 1:
t1 = time.time()
s = socket(AF_INET, SOCK_STREAM)
t2 = time.time()
- s.connect(host, port)
+ s.connect((host, port))
t3 = time.time()
i = 0
while i < count:
else:
port = ECHO_PORT
s = socket(AF_INET, SOCK_DGRAM)
- s.bind('', port)
+ s.bind(('', port))
print 'udp echo server ready'
while 1:
data, addr = s.recvfrom(BUFSIZE)
port = ECHO_PORT
addr = host, port
s = socket(AF_INET, SOCK_DGRAM)
- s.bind('', 0)
+ s.bind(('', 0))
print 'udp echo client ready, reading stdin'
while 1:
line = sys.stdin.readline()