From 802a699edfcc99c2bbdc3e7bbec34f70c57138fc Mon Sep 17 00:00:00 2001 From: fosanz Date: Fri, 19 Jan 2024 18:27:07 +0100 Subject: [PATCH] Initial commit --- .idea/.gitignore | 8 +++++++ .idea/TCPNetworking.iml | 10 ++++++++ .idea/inspectionProfiles/Project_Default.xml | 23 +++++++++++++++++++ .../inspectionProfiles/profiles_settings.xml | 6 +++++ .idea/misc.xml | 7 ++++++ .idea/modules.xml | 8 +++++++ .idea/vcs.xml | 6 +++++ client.py | 15 ++++++++++++ server.py | 18 +++++++++++++++ 9 files changed, 101 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/TCPNetworking.iml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 client.py create mode 100644 server.py diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/TCPNetworking.iml b/.idea/TCPNetworking.iml new file mode 100644 index 0000000..2c80e12 --- /dev/null +++ b/.idea/TCPNetworking.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..8413d42 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,23 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..9689a5a --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..7494264 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/client.py b/client.py new file mode 100644 index 0000000..76864bb --- /dev/null +++ b/client.py @@ -0,0 +1,15 @@ +import socket + +host = '192.168.50.106' +port = 2000 + +with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: + s.connect((host, port)) + while True: + data = input('Enter data to send: ') + s.send(data.encode('utf-8')) + if data == 'exit': + break + + data = s.recv(1024) + print('Received data: ', data.decode('utf-8')) diff --git a/server.py b/server.py new file mode 100644 index 0000000..d3bea55 --- /dev/null +++ b/server.py @@ -0,0 +1,18 @@ +import socket + +host = '' +port = 2000 + +with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: + s.bind((host, port)) + s.listen() + conn, addr = s.accept() + with conn: + print('Connected by', addr) + while True: + data = conn.recv(1024) + if data == b'exit': + break + + print('Received data: ', data) + conn.send(data + b' from server') \ No newline at end of file