Created
June 22, 2020 11:02
-
-
Save ahmedfgad/6ab42e363dd1040aa0ee05d86d8fab31 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
| import socket | |
| import pickle | |
| soc = socket.socket() | |
| print("Socket is created.") | |
| soc.connect(("localhost", 10000)) | |
| print("Connected to the server.") | |
| msg = "A message from the client." | |
| msg = pickle.dumps(msg) | |
| soc.sendall(msg) | |
| print("Client sent a message to the server.") | |
| received_data = soc.recv(8) | |
| received_data = pickle.loads(received_data) | |
| print("Received data from the client: {received_data}".format(received_data=received_data)) | |
| soc.close() | |
| print("Socket closed.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment