客户端和服务器之间的通信无法正常工作

时间:2019-10-26 20:47:06

标签: python sockets networking server client

我想编写一个客户端服务器程序,但是它被卡在switch函数中。

我最初写了一个简单的程序,但是后来我添加了switch函数,它停止了工作。没有开关的程序运行良好;它连接到客户端并显示相应的消息。您可以在此处查看服务器应用程序:

 import socket

    s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
    s.bind((socket.gethostname(),1234))
    s.listen(10);
    """subprocess.call('dovecot')"""
    while True : 
        clientsocket, address = s.accept()
        print(f"Connection from {address} has been established!")
        print("Welcome!Dovecot is now running! Enter 2-20:")
    print("Choose command from 2-20:")
    command = int(msg= s.recv(2048) )

    def switch_demo(command):
            switcher = {
                    2:print("subprocess.call('dovecot')"),
                    3:'Monday',
                    4:'Tuesday',
                    5:'Wednesday',
                    6:'Thursday',
                    7:'Friday',
                    8:'Saturday',

                 }

0 个答案:

没有答案