Skip to content

Instantly share code, notes, and snippets.

@aledruetta
Last active March 27, 2021 12:57
Show Gist options
  • Select an option

  • Save aledruetta/3f1aba1d678fa1b682265ce2522a2ecb to your computer and use it in GitHub Desktop.

Select an option

Save aledruetta/3f1aba1d678fa1b682265ce2522a2ecb to your computer and use it in GitHub Desktop.
# server.py
from socket import *
HOST = gethostname()
PORT = 5001
def setup():
s = socket(AF_INET, SOCK_STREAM)
s.bind((HOST, PORT))
s.listen()
return s
def upper_rpc(s):
(conn, addr) = s.accept()
data = conn.recv(1024)
if data:
conn.send(data.upper())
print(f"'{data.decode()}' from {addr}")
if __name__ == "__main__":
s = setup()
while True:
upper_rpc(s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment