Skip to content

Instantly share code, notes, and snippets.

@songritk
Last active February 7, 2019 12:01
Show Gist options
  • Save songritk/8b0a07008044c49d62527591a14fc23e to your computer and use it in GitHub Desktop.
Save songritk/8b0a07008044c49d62527591a14fc23e to your computer and use it in GitHub Desktop.
ตัวอย่าง server เปลี่ยนข้อความตัวอักษรเป็นตัวพิมพ์ใหญ่ สำหรับการเรียนวิชา Computer Networks, NPU Computer Engineer
#!/usr/bin/env python3
from socket import *
serverPort = 12002
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.sendto(modifiedMessage.encode(), clientAddress)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment