我正在使用这两个程序在我的两台计算机之间进行通信,其中一台是我通过 ssh 连接的,并且我不会在任何一方返回任何内容。它只是运行而不发送任何内容
客户
import sys
from socket import socket, AF_INET, SOCK_DGRAM
SERVER_IP = '127.0.0.1'
PORT_NUMBER = 5000
SIZE = 1024
print ("Test client sending packets to IP {0}, via port {1}\n".format(SERVER_IP, PORT_NUMBER))
mySocket = socket( AF_INET, SOCK_DGRAM )
while True:
mySocket.sendto('cool',(SERVER_IP,PORT_NUMBER))
sys.exit()
服务器
from socket import socket, gethostbyname, AF_INET, SOCK_DGRAM
import sys
PORT_NUMBER = 5000
SIZE = 1024
hostName = gethostbyname( '0.0.0.0' )
mySocket = socket( AF_INET, SOCK_DGRAM )
mySocket.bind( (hostName, PORT_NUMBER) )
print ("Test server listening on port {0}\n".format(PORT_NUMBER))
while True:
(data,addr) = mySocket.recvfrom(SIZE)
print data
sys.ext()
我可能做错了什么?