• 2019.10.22

    client

    import socket
    
    client = socket.socket()
    client.connect(
        ('127.0.0.1',8888)
    )
    
    
    while 1:
        msg = input('input>>>')
        if  msg == 'q':
            break
        client.send(msg.encode('utf-8'))
        data = client.recv(1024).decode('utf-8')
        print(data)
    
    client.close()

    server

    import socket
    from  multiprocessing  import Process,Queue
    import threading
    import socketserver
    
    # q = Queue(4)
    
    server = socket.socket()
    server.bind(
        ('127.0.0.1', 8888)
    )
    server.listen(3)
    
    def se():
    
    
        while 1:
            conn,addr = server.accept()
            print(addr)
    
            while 1:
                try:
                    data = conn.recv(1024).decode('utf-8')
                    print(data)
                    conn.send(data.encode('utf-8'))
    
                except Exception as e:
                    print(e)
                    break
    
            conn.close()
    
    
    
    if __name__ == '__main__':
    
        p1 = threading.Thread(target=se)
        p2 = threading.Thread(target=se)
        p3 = threading.Thread(target=se)
        p1.start()
        p2.start()
        p3.start()
    本站公众号
       欢迎关注本站公众号,获取更多程序园信息
    开发小院
    4887铁筼结果开奖结果小说 钦州市| 涟水县| 闻喜县| 林口县| 象州县| 忻州市| 建湖县| 沙湾县| 曲靖市| 鄯善县| 东乡族自治县| 桐庐县| 静乐县| 新闻| 平安县| 康马县| 特克斯县| 米易县| 无锡市| 南阳市| 河东区| 磐安县| 淳化县| 新竹县| 绥宁县| 陇南市| 汉沽区| 西城区| 锡林浩特市| 丹棱县| 自治县| 华宁县| 梧州市| 积石山| 柳林县| 白朗县| 阿拉善盟| http://fa.hz0j1r3vo.fun http://fa.hz0j1r1vo.fun http://fa.hz0j1r6vo.fun http://fa.hz0j1r4vo.fun http://fa.hz0j2r9vo.fun