Hi all,
I'm trying to write a typical chat server application with twisted. At this moment, all is working fine except for some strange behaviour with sendLine and connectionLost funcs. Let me explain the problem:
- I have a server on the internet.
- I connect two PCs (2 clients) from the same LAN through a router to that server
- All is working fine until I disconnect the LAN of one of those PC (The client is disconnected but the server doesn't know about it). Just to test a typical wireless disconnection without closing sockets, etc...
- After disconnecting I try to send some messages through the remaining clients to all clients through this function:
def sendMessageToAllClients(self, mesg,reqClient):
for client in self.clientProtocols:
dataLength = str(len(mesg))
if (len(dataLength) < 8):
dif = 8 - len(dataLength)
dataLength = "0"*dif + dataLength
print "Enviando a:",str(client)
client.sendLine(dataLength+mesg)
client.clearLineBuffer()
As you can see, I send a message to all clients, including the one disconnected because the server doesn't
know at this moment that the client is "out". I'm able to send 6 or 7 messages to the remaining client but
after that, the connection get lost. I would expect to have a connectionLost with the client offline but actually
I got a connectionLost in both clients and I don't know why. The server disconnect both clients with "non clean fashion".
Any help or advice would be highly appreciated.
Regards,
David
------------------------------------------------------------------------------------------------------------------------------------------------
Este mensaje es confidencial y atañe exclusivamente a las personas a las que va dirigido.
Cualquier opinión en el contenida, es exclusivo de su autor y no representa necesariamente
la opinion de UNIPOST, S.A.
Si Ud. no es el destinatario del mensaje, considerese advertido que lo ha recibido por error
y que cualquier difusión o copia estan terminantemente prohibidos. Si ha recibido por error,
por favor comuniquelo a UNIPOST, S.A. al número +34 93 223 25 52 o correo electrónico
a