socket_udp客户端循环输入
server--------------
#!/usr/bin/env python
# encoding: utf-8
# Date: 2018/6/7
from socket import *
server = socket(AF_INET, SOCK_DGRAM)
server.bind(('127.0.0.1', 8808))
while True:
data, client_addr = server.recvfrom(1024)
print(data)
server.sendto(data.upper(), client_addr)
server.close()
client----------------
#!/usr/bin/env python
# encoding: utf-8
# Date: 2018/6/7
from socket import *
client = socket(AF_INET, SOCK_DGRAM)
while True:
msg = input('>>>:').strip()
client.sendto(msg.encode('utf-8'), ('127.0.0.1', 8808))
data, server_addr = client.recvfrom(1024)
print(data, server_addr)
client.close()