summaryrefslogtreecommitdiff
path: root/python/tcp_sockets/client.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/tcp_sockets/client.py')
-rw-r--r--python/tcp_sockets/client.py16
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()