swadhinbiswas update · 4/20/2024
1661c90
21 lines · 420 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import socket
import time

host = '192.168.0.101'
port=9090

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))

time.sleep(2)
def recive():
  while True:
    message = s.recv(1024).decode('utf-8')
    print(f"Server: {message}")
    s.send('Client: I received your message'.encode('utf-8'))
    time.sleep(2)
    s.send('Hello, Server'.encode('utf-8'))
    time.sleep(2)
    break
  
recive()