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 <[email protected]>.

This e-mail is confidential and intended solely for the use of the individual 
to whom it is addressed.
Any opinions presented are solely those of the author and do not necessarily 
represent those of 
UNIPOST, S.A.
If you are not the intended recipient, be advised that you have received this 
e-mail in error and that 
dissemination, forwarding or copying of this e-mail is strictly prohibited. If 
you have received this 
e-mail in error please notify it to UNIPOST, S.A. by telephone on number +34 93 
223 25 52 or by
e-mail to <[email protected]>.
------------------------------------------------------------------------------------------------------------------------------------------------
_______________________________________________
Twisted-web mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web

Reply via email to