client.connect(("localhost",6969)) client.send(b"Hello World") data_receive=client.recv(1024) print("接收到的数据是:",data_receive) client.close() 1. 2. 3. 4. 5. 6. 7. 8. 9. #服务器端 import socket server=socket.socket() server.bind(("localhost",6969)) server.listen() print...
tcp_server_socket.bind(("", 5555)) # 程序结束,释放端口号,端口号复用 tcp_server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, True) # 设置监听,把主动套接字变成被动套接字,服务端套接字只负责接收客户端的连接请求 tcp_server_socket.listen(128) while True: service_client_socket, i...