• <menu id="ckmo6"></menu>
  • <input id="ckmo6"><u id="ckmo6"></u></input>
    <menu id="ckmo6"></menu>
  • <input id="ckmo6"><acronym id="ckmo6"></acronym></input>
  • 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()
    本站公众号
       欢迎关注本站公众号,获取更多程序园信息
    开发小院
    香港精选免费资料大全 永春县| 兴国县| 邢台县| 阜康市| 开平市| 红桥区| 舞钢市| 桦南县| 柞水县| 广昌县| 措勤县| 乌拉特后旗| 海南省| 汉寿县| 宜都市| 邓州市| 兴隆县| 南郑县| 宜都市| 嘉义县| SHOW| 公安县| 岗巴县| 射洪县| 类乌齐县| 盐城市| 博爱县| 沙坪坝区| 湘乡市| 突泉县| 昭苏县| 日照市| 枣阳市| 徐水县| 千阳县| 清丰县| 河间市| http://fa.hz0j0r2vo.fun http://fa.hz0j1r8vo.fun http://fa.hz0j1r5vo.fun http://fa.hz0j1r4vo.fun http://fa.hz0j2r5vo.fun