国产xxxx99真实实拍_久久不雅视频_高清韩国a级特黄毛片_嗯老师别我我受不了了小说

資訊專欄INFORMATION COLUMN

UDP-python

?xiaoxiao, / 2151人閱讀

Server.py
import socket

port = 8080
host = "localhost"
ADDR = (host, port)

udpServer = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

udpServer.bind(ADDR)

while True:
    data, addr = udpServer.recvfrom(1024)
    replay = str(data) + "....ok"
    udpServer.sendto(replay.encode(), addr)
    print(replay)

udpServer.close()
Client.py
HOST = "localhost"
PORT = 8080
BUFSIZE = 1024
ADDR = (HOST, PORT)

udpCliSock = socket(AF_INET, SOCK_DGRAM)

while True:
    data = input(">")
    if not data:
        break
    udpCliSock.sendto(data.encode(), ADDR)
    data, ADDR = udpCliSock.recvfrom(BUFSIZE)
    if not data:
        break
    print("server replay...:",data)

udpCliSock.close()

udp 和 tcp 的最大區(qū)別是server 無需監(jiān)聽客戶端的鏈接

文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請注明本文地址:http://specialneedsforspecialkids.com/yun/40619.html

相關(guān)文章

發(fā)表評論

0條評論

最新活動
閱讀需要支付1元查看
<