# -*- coding: utf-8 -*-
"""
Created on Mon Apr 17 19:11:30 2023
@author: LittleYellowFlower
"""
from socket import *
serverPort = 12000
serverSocket = socket(AF_INET, SOCK_DGRAM)
serverSocket.bind(('',serverPort))
print("The server is ready to receive")
while True:
message, clientAddress = serverSocket.recvfrom(2048)
modifiedMessage = message.decode().upper()
serverSocket.sento(modifiedMessage.encode(), clientAddress)
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 17 19:04:42 2023
@author: LittleYellowFlower
"""
from socket import *
serverName = 'hostname'
serverPort = 12000
clientSocket = socket(AF_INET,SOCK_DGRAM)
message = raw_input('Input lowercase sentence:')
clientSocket.sendto(message.encode(),(serverName, serverPort))
mosifiedMessage, serverAddress == clientSocket.recvfrom(2048)
print(modifiedMessage.decode())
clientSocket.close()
标签:udp,socket,serverSocket,serverPort,接字,message,clientSocket,modifiedMessage
From: https://www.cnblogs.com/zlr585/p/17327317.html