我正在使用Python套接字进行P2P连接,并且作为一个小安全措施,我做了它,以便计算机发送一个ID,服务器读取它并继续程序或终止它。
客户端
connectionID = "123456789"
m.send(connectionID.encode('utf-8'))
服务器
thisID = "123456789"
while True:
print ("Waiting for connection")
sc, address = s.accept()
print (address)
connectionID = sc.recv(1024).decode('utf-8')
if connectionID == "123456789":
print ("Connected")
while True:
message = sc.recv(1024).decode('utf-8')
eval(message)
else:
print ("Not the correct connection ID")
我总是得到"Not the correct connection id"