我有一个基本的python套接字,如:
server.py
import socket
ip = '192.168.2.231'
port = 2005
addr = (ip, port)
serv_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
serv_socket.bind(addr)
serv_socket.listen(2)
con, cliente = serv_socket.accept()
receive = con.recv(1024)
if receive == '0123456789':
#print "Accepted ACK"
HERE - how can i send a message to client.py back
serv_socket.close()
我如何回应client.py发送的ACK是否正确? 在第16行(server.py)我执行IF并打印一条消息,我想发回一条消息给client.py说ACK无效/无效
答案 0 :(得分:1)
您只需使用客户端套接字发送回复。
con, cliente = serv_socket.accept()
receive = con.recv(1024)
if receive == '0123456789':
con.send("ACK")
serv_socket.close()