Open a connection to the desired host. :param address: The address of the host to connect to. :param port: The port of the host to connect to. :return: The socket connected to the host.
(address: str, port: int)
| 46 | |
| 47 | |
| 48 | def open_connection(address: str, port: int) -> socket.socket: |
| 49 | """Open a connection to the desired host. |
| 50 | |
| 51 | :param address: The address of the host to connect to. |
| 52 | :param port: The port of the host to connect to. |
| 53 | :return: The socket connected to the host. |
| 54 | """ |
| 55 | sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
| 56 | sock.connect((address, port)) |
| 57 | print(f'Connected to {address}:{port}') |
| 58 | return sock |
| 59 | |
| 60 | |
| 61 | def send_slow_post(sock: socket.socket, server_hostname: str, send_time: int, finish_request: bool) -> None: |