diff --git "a/work/K3320/\320\241\320\272\320\262\320\276\321\200\321\206\320\276\320\262_\320\230\320\262\320\260\320\275/lab6/task1/client.py" "b/work/K3320/\320\241\320\272\320\262\320\276\321\200\321\206\320\276\320\262_\320\230\320\262\320\260\320\275/lab6/task1/client.py" new file mode 100644 index 000000000..1881ce7a4 --- /dev/null +++ "b/work/K3320/\320\241\320\272\320\262\320\276\321\200\321\206\320\276\320\262_\320\230\320\262\320\260\320\275/lab6/task1/client.py" @@ -0,0 +1,11 @@ +import socket + +HOST = 'localhost' +PORT = 4321 + +with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: + s.connect((HOST, PORT)) + s.sendall(b'Hello, server') + data = s.recv(1024) + +print('Received from server:', data.decode()) \ No newline at end of file diff --git "a/work/K3320/\320\241\320\272\320\262\320\276\321\200\321\206\320\276\320\262_\320\230\320\262\320\260\320\275/lab6/task1/server.py" "b/work/K3320/\320\241\320\272\320\262\320\276\321\200\321\206\320\276\320\262_\320\230\320\262\320\260\320\275/lab6/task1/server.py" new file mode 100644 index 000000000..48c6de8dd --- /dev/null +++ "b/work/K3320/\320\241\320\272\320\262\320\276\321\200\321\206\320\276\320\262_\320\230\320\262\320\260\320\275/lab6/task1/server.py" @@ -0,0 +1,15 @@ +import socket + +HOST = 'localhost' +PORT = 4321 + +with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: + s.bind((HOST, PORT)) + s.listen() + print('Server is listening...') + conn, addr = s.accept() + with conn: + print('Connected by', addr) + data = conn.recv(1024) + print('Received from client:', data.decode()) + conn.sendall(b'Hello, client') \ No newline at end of file diff --git "a/work/K3320/\320\241\320\272\320\262\320\276\321\200\321\206\320\276\320\262_\320\230\320\262\320\260\320\275/lab6/task2/client.py" "b/work/K3320/\320\241\320\272\320\262\320\276\321\200\321\206\320\276\320\262_\320\230\320\262\320\260\320\275/lab6/task2/client.py" new file mode 100644 index 000000000..34d87e8d2 --- /dev/null +++ "b/work/K3320/\320\241\320\272\320\262\320\276\321\200\321\206\320\276\320\262_\320\230\320\262\320\260\320\275/lab6/task2/client.py" @@ -0,0 +1,17 @@ +import socket + +HOST = 'localhost' +PORT = 23456 + +with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: + s.connect((HOST, PORT)) + print("Choose operation:") + print("1 - Pythagorean theorem") + choice = input("Enter choice: ") + + if choice == '1': + a = input("Enter a: ") + b = input("Enter b: ") + s.sendall(f"{choice} {a} {b}".encode()) + result = s.recv(1024).decode() + print("Result:", result) \ No newline at end of file diff --git "a/work/K3320/\320\241\320\272\320\262\320\276\321\200\321\206\320\276\320\262_\320\230\320\262\320\260\320\275/lab6/task2/server.py" "b/work/K3320/\320\241\320\272\320\262\320\276\321\200\321\206\320\276\320\262_\320\230\320\262\320\260\320\275/lab6/task2/server.py" new file mode 100644 index 000000000..183322fed --- /dev/null +++ "b/work/K3320/\320\241\320\272\320\262\320\276\321\200\321\206\320\276\320\262_\320\230\320\262\320\260\320\275/lab6/task2/server.py" @@ -0,0 +1,18 @@ +import socket +import math + +HOST = 'localhost' +PORT = 23456 + +with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: + s.bind((HOST, PORT)) + s.listen() + print('Server listening for math operations...') + conn, addr = s.accept() + with conn: + print('Connected by', addr) + data = conn.recv(1024).decode().split() + choice, a, b = data + if choice == '1': + result = math.sqrt(float(a)**2 + float(b)**2) + conn.sendall(str(result).encode()) \ No newline at end of file diff --git "a/work/K3320/\320\241\320\272\320\262\320\276\321\200\321\206\320\276\320\262_\320\230\320\262\320\260\320\275/lab6/task3/index.html" "b/work/K3320/\320\241\320\272\320\262\320\276\321\200\321\206\320\276\320\262_\320\230\320\262\320\260\320\275/lab6/task3/index.html" new file mode 100644 index 000000000..e01b539f3 --- /dev/null +++ "b/work/K3320/\320\241\320\272\320\262\320\276\321\200\321\206\320\276\320\262_\320\230\320\262\320\260\320\275/lab6/task3/index.html" @@ -0,0 +1,9 @@ + + +
+