Помогите, пожалуйста, разобраться почему в коде, который приведен ниже, после нескольких раз выполнения recv, перестает генериться эксепшин по таймайту
serverSock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
serverSock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
serverSock.connect((serverHost, serverPort))
socksSock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
socksSock.connect((socksServName, socksServPort))
print "Connect to server successfuly"
socksSock.settimeout(2.0)
while(1):
clientId = (int) ( readControlField(serverSock) )
lenMsg = (int) ( readControlField(serverSock) )
print "Wait message from client"
msg = readMessage(serverSock, lenMsg)
try:
print "Send to socks server: \"",msg[0],"\" "
socksSock.sendall(msg[0])
except:
print "Error write data to server"
break
msg[0] = ""
lenMsg = 0
try:
while(True):
msg[0] += socksSock.recv(1)
print ".",
except socket.timeout:
print "timeout"
msg[0] = (str)(clientId) + "," + (str)( len(msg[0]) ) + "," + msg[0]
print "Send to client: \"",msg[0],"\""
serverSock.sendall(msg[0])
serverSock.close()