为了做UDP的测试,采用了nc和Python的服务器端。
nc的安装和使用:
yum install -y nc nc -vuz 35.194.168.243 5001
Python的UDP服务器端小程序:
# -*- coding: UTF-8 -*- import socket address = ('0.0.0.0',5001) s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM) s.bind(address) while True: data, addr = s.recvfrom(2048) if not data: print 'client has exist' break print 'received:',data, 'from',addr s.close()