首页 > 代码库 > python socket编程 UDP
python socket编程 UDP
python socket编程 UDP
by 伍雪颖
server.py
import socket BUF_SIZE = 1024 server_addr = ('127.0.0.1',8888) server = socket.socket(socket.AF_INET,socket.SOCK_DGRAM) server.bind(server_addr) while True: print "waiting for data" data,client_addr = server.recvfrom(BUF_SIZE) print 'Connected by ',client_addr,' Receive data : ',data server.sendto(data,client_addr) server.close()
client.py
import socket import struct BUF_SIZE = 1024 server_addr = ('127.0.0.1',8888) client = socket.socket(socket.AF_INET,socket.SOCK_DGRAM) while True: data = http://www.mamicode.com/raw_input("Please input some string > ")>
python socket编程 UDP
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。