我正在尝试使用UDP作为传输协议编写一个简单的套接字(服务器端)与同一台机器上的进程通信。这是代码:
from socket import *
serverPortS = 1234
serverSocket = socket(AF_INET, SOCK_DGRAM)
serverSocket.bind(('localhost', serverPortS))
print ('Il server e pronto a ricevere')
messageS, clientAddressS =serverSocket.recvfrom(2048)
modifiedMessageS = messageS.upper()
serverSocket.sendto(modifiedMessageS, clientAddressS)
serverSocket.close()
控制台给我错误,只是启动服务器(还没有客户端):
Traceback (most recent call last):
File "E:\Laboratorio Python\udp_server.py", line 12, in <module>
serverSocket.bind(('localhost', serverPortS))
OSError: [WinError 10048] Only one usage of each socket address (protocol/network address/port) is normally permitted
我不知道如何修复它或它意味着什么,在网上搜索我发现了更复杂的问题;我很乐意听到一个可能的解决方案!