Created
December 10, 2013 06:13
-
-
Save barnash/7886427 to your computer and use it in GitHub Desktop.
קוד מתרגול 6
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 | |
| client = socket.socket() | |
| client.connect(("127.0.0.1", 5678)) | |
| print("Connected! I'm the man/woman!") | |
| client.send("Hey you!".encode()) | |
| message = client.recv(2000).decode() | |
| print("Server sent " + message) | |
| client.close() |
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 | |
| server = socket.socket() | |
| server.bind(("0.0.0.0", 5678)) | |
| server.listen(0) | |
| while True: | |
| client_socket, address = server.accept() | |
| print(address) | |
| print("Connected!") | |
| message = client_socket.recv(2000).decode() | |
| print ("Client sent message " + message) | |
| client_socket.send("Bye bye".encode()) | |
| client_socket.close() | |
| server.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment