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
| received_data = b'' | |
| if connected: | |
| while True: | |
| recv_start_time = time.time() | |
| time_struct = time.gmtime() | |
| date_time = "Waiting to Receive Data Starting from {day}/{month}/{year} {hour}:{minute}:{second} GMT".format(year=time_struct.tm_year, month=time_struct.tm_mon, day=time_struct.tm_mday, hour=time_struct.tm_hour, minute=time_struct.tm_min, second=time_struct.tm_sec) | |
| print(date_time) | |
| recv_timeout = 5 | |
| received_data, status = recv(connection, 8, recv_timeout) | |
| print("Received data from the client: {received_data}".format(received_data=received_data)) |
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
| def recv(connection, buffer_size, recv_timeout): | |
| recv_start_time = time.time() # Time at which last chunk is received from the client. | |
| received_data = b"" | |
| while True: | |
| try: | |
| data = connection.recv(buffer_size) | |
| received_data += data | |
| if data == b'': # Nothing received from the client. | |
| received_data = b"" |
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 time | |
| def recv(connection, buffer_size, recv_timeout): | |
| received_data = b"" | |
| while (received_data)[-2] != '.': | |
| try: | |
| data = connection.recv(buffer_size) | |
| received_data += data | |
| except BaseException as e: | |
| print("Error Receiving Data from the Client: {msg}.\n".format(msg=e)) |
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.bind(("localhost", 10000)) | |
| print("Socket is bound to an address & port number.") | |
| soc.listen(1) |
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.bind(("localhost", 10000)) | |
| print("Socket is bound to an address & port number.") | |
| soc.listen(1) |
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." |
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." |
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.bind(("localhost", 10000)) | |
| print("Socket is bound to an address & port number.") | |
| soc.listen(1) |
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 | |
| soc = socket.socket() | |
| print("Socket is created.") | |
| soc.bind(("localhost", 10000)) | |
| print("Socket is bound to an address & port number.") | |
| soc.listen(1) | |
| print("Listening for incoming connection ...") |
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 | |
| soc = socket.socket() | |
| print("Socket is created.") | |
| soc.bind(("localhost", 10000)) | |
| print("Socket is bound to an address & port number.") | |
| soc.listen(1) | |
| print("Listening for incoming connection ...") |