python_socket
# socket_server.py import socket s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM) s.bind((‘‘,8089)) while True: # Receive up to 1,024 bytes in a datagram data, addr = s.recvfrom(1024) print "Received:", data, "from", addr
# socket_client.py import socket s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) port = 8089 host = "localhost" while True: msg = raw_input(‘Enter message:‘) s.sendto(msg, (host, port))
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。