-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
53 lines (41 loc) · 1.2 KB
/
server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import time
import socket
import os
def clear():
os.system('cls' if os.name == 'nt' else 'clear')
clear()
def host_server():
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
host = "192.168.178.22"
port = 8080
s.bind((host, port))
print("waiting for EDVA")
s.listen(1)
global conn
conn, addr = s.accept()
print(addr, "Has connected to Remote")
send_command()
def send_command():
command = input(str("Command: "))
conn.send(command.encode())
print("Command has been sent. Waiting for confirmation")
data = conn.recv(1024)
data = data.decode()
if data == "shutdown":
print("shutdown command received and executed")
elif data == "sleep":
print("sleep command received and executed")
elif data == "test":
print("test command received and executed")
send_command()
elif data == "exit":
print("exit command received and executed")
exit(0)
elif data == "error":
print("some shit occurred, check client")
send_command()
if __name__ == '__main__':
print("server running...")
time.sleep(1)
host_server()