equal
deleted
inserted
replaced
23 |
23 |
24 def communicate(data,host,port): |
24 def communicate(data,host,port): |
25 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
25 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
26 try: |
26 try: |
27 sock.connect((host,port)) |
27 sock.connect((host,port)) |
28 sock.sendall(data) |
28 sock.sendall(data+'\n') |
29 received = '' |
29 received = '' |
30 cont = True |
30 cont = True |
31 counter = 0 |
31 counter = 0 |
32 while cont and counter < 100000: |
32 while cont and counter < 100000: |
33 rec = sock.recv(4096) |
33 rec = sock.recv(4096) |
34 if rec == 'stop': |
34 if rec.endswith('stop'): |
35 cont = False |
|
36 elif rec.endswith('stop'): |
|
37 cont = False |
35 cont = False |
38 received += rec[:-4] |
36 received += rec[:-4] |
39 else: |
37 else: |
40 received += rec |
38 received += rec |
41 counter += 1 |
39 counter += 1 |