socket
我用python中的模块制作了一个简单的服务器和一个简单的客户端。
服务器:
# server.py
import socket
s = socket.socket()
host = socket.gethostname()
port = 1234
s.bind((host, port))
s.listen(5)
while True:
c, addr = s.accept()
print 'Got connection from', addr
c.send('Thank you for your connecting')
c.close()
和客户:
#client.py
import socket
s = socket.socket()
host = socket.socket()
port = 1234
s.connect((host, port))
print s.recv(1024)
我启动了服务器,然后启动了 4 个客户端,并在服务器的控制台中得到输出,如下所示:
Got connection from ('192.168.0.99', 49170)
Got connection from ('192.168.0.99', 49171)
Got connection from ('192.168.0.99', 49172)
Got connection from ('192.168.0.99', 49173)
元组的第二部分是什么?