-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.py
32 lines (30 loc) · 885 Bytes
/
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
import socket
from time import sleep
host = '0.0.0.0'
port = 9999
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((host, port))
s.listen(1)
while True:
print('\nListening for a client at',host , port)
conn, addr = s.accept()
print('\nConnected by', addr)
try:
print('\nWaiting for user input...\n')
'''
with open('iris_test.csv') as f:
for line in f:
out = line.encode('utf-8')
print('Sending line',line)
conn.send(out)
sleep(10)
print('End Of Stream.')
'''
while 1:
sentence = raw_input("What is your sentence? \n")
#sentence = sentence.encode('utf-8')
conn.send(sentence + '\n')
#conn.close()
except:
print ('Error Occured.\n\nClient disconnected.\n')
conn.close()