UDPClient.py
from socket import *
serverName = '~~~.~~~.123.171'
serverPort = 12000

while 1:
    clientSocket = socket(AF_INET, SOCK_DGRAM)        # this creates socket and SOCK_DGRAM indicates it is UDP connection
    message = raw_input('Input lowercase sentence:')
    clientSocket.sendto(message, (serverName, serverPort))
    modifiedMessage, serverAddress = clientSocket.recvfrom(2048)
    print modifiedMessage

    clientSocket.close() 



UDPServer.py

from socket import *

serverPort = 12000            # arbitrarily chosen port number (that is available for use)

serverSocket = socket(AF_INET, SOCK_DGRAM)        # this creates socket and SOCK_DGRAM indicates it is UDP connection

serverSocket.bind(('', serverPort))                              

print "The sever is ready to receive"

while 1:                                                            

    message, clientAddress = serverSocket.recvfrom(2048)

    modifiedMessage = message.upper()

    serverSocket.sendto(modifiedMessage, clientAddress)



Open up Command Prompt -> enter 'IDLE'

or

Go to 'Start' -> enter 'IDLE" in search box


to initiate Python GUI 





File -> New FIle










Run -> Run Module



Note that this can run only when the UDP Server is running on the other host!








WRITTEN BY
서상호

,