小编Raj*_*Raj的帖子

socket编程问题 - python

我正在为我的大学项目做一个客户端 - 服务器项目,我们必须将登录分配给客户端.

客户端系统将每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)

python sockets multithreading client-server

2
推荐指数
1
解决办法
2164
查看次数

标签 统计

client-server ×1

multithreading ×1

python ×1

sockets ×1