##// END OF EJS Templates

File last commit:

r91:92
r93:94
Show More
server.py
39 lines | 791 B | text/x-python | PythonLexer
import socket
import time
host = "192.168.1.117"
s = socket.socket()
s.bind((host, 5500))
while True:
print "waiting client..."
s.listen(1)
sc, addr = s.accept()
all = ""
# i=0 #to avoid infinit loop
cnt = 0;
first = 0;
while True:
recibido = sc.recv(1024)
all = all + recibido
cnt = len(all)
if first == 0:
first = 1;
lng = int(all[12:18]) # 6 bytes to get the frame size
# i = i + 1
# if cnt == lng or i == 30:
if cnt == lng:
break
print "\nSize of frame:" + str(lng)
print "\nNumber of bytes received:" + str(cnt)
sc.close()
s.close()
#print len(recibido)