我正在为我的大学项目做一个客户端 - 服务器项目,我们必须将登录分配给客户端.
客户端系统将每2秒请求其状态(以检查客户端是锁定还是解锁).和服务器将接受客户端请求并将客户端状态回复给系统.
但问题是服务器线程没有响应客户端请求.
客户线程:
def checkPort():
while True:
try:
s = socket.socket()
s.connect((host, port))
s.send('pc1') # send PC name to the server
status = s.recv(1024) # receive the status from the server
if status == "unlock":
disableIntrrupts() # enable all the functions of system
else:
enableInterrupts() # enable all the functions of system
time.sleep(5)
s.close()
except Exception:
pass
Run Code Online (Sandbox Code Playgroud)
服务器线程:
def check_port():
while True:
try:
print "hello loop is repeating"
conn, addr = s.accept()
data = conn.recv(1024)
if exit_on_click …Run Code Online (Sandbox Code Playgroud)