diff options
| author | pants <niklasjo2004@gmail.com> | 2026-09-21 14:17:03 -0700 |
|---|---|---|
| committer | pants <niklasjo2004@gmail.com> | 2026-09-21 14:17:03 -0700 |
| commit | 7b21727285e50b0b050c4ddd70d07542229c5366 (patch) | |
| tree | 5d369153c5df5b41f3750d25479a68f20169c8ff /python/tcp_sockets/client.py | |
init
Diffstat (limited to 'python/tcp_sockets/client.py')
| -rw-r--r-- | python/tcp_sockets/client.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/python/tcp_sockets/client.py b/python/tcp_sockets/client.py new file mode 100644 index 0000000..3e6c22a --- /dev/null +++ b/python/tcp_sockets/client.py @@ -0,0 +1,16 @@ +import socket + +client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + +server_address = input("address to connect to: ") +server_port = input("port to connect through: ") + +client_socket.connect((server_address, int(server_port))) + +while 1: + transmission = input("text to send: ") + client_socket.send(transmission.encode('utf-8')) + response = client_socket.recv(8192).decode('utf-8') + print("server replied: " + response) + +client_socket.close() |
