-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.py
More file actions
36 lines (35 loc) · 692 Bytes
/
server.py
File metadata and controls
36 lines (35 loc) · 692 Bytes
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
from socket import *
import pinfo, common, maze, sys, os
try:
HOST = ''
PORT = 9876
s = socket(AF_INET6,SOCK_STREAM)
s.bind((HOST,PORT))
s.listen(5)
quitflag=False
while True:
conn,addr = s.accept()
print 'Connected by',addr
if os.fork() == 0:
#Child
cli = pinfo.pinfo(conn,addr)
prompt = '> '
while True:
if cli.exploring:
cli.process('show')
conn.sendall(prompt)
for line in conn.recv(1024)[:-2].split(','):
line = line.strip()
if line == 'quit':
quitflag=True
break
if line == '':
continue
cli.process(line)
if quitflag:
break
conn.close()
else:
conn.close()
except KeyboardInterrupt:
pass