Last active
March 27, 2021 12:57
-
-
Save aledruetta/3f1aba1d678fa1b682265ce2522a2ecb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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