我在s.sendto(data,addr)
处遇到python套接字问题
和我的代码一样
import socket
def Main():
host = '127.0.0.1'
port = 5000
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind((host, port))
print("server started")
while True:
data, addr = s.recvfrom(1024)
print ("message from : "+ str(addr))
print ("from connected user : "+ str(data))
data = str(data.upper())
print ("sending : "+ str(data))
socket.sendto(data, addr)
和结果
socket.sendto(data, addr)
AttributeError: module 'socket' has no attribute 'sendto'
s.close()
if __name__ == '__main__':
Main()
并且在UdpClient s.sendto
正在运行