Re: How to detetct that a socket was closed by the server

41 views
Skip to first unread message

Christoffer Lernö

unread,
Oct 16, 2012, 3:04:52 PM10/16/12
to naga-...@googlegroups.com
Hello Christian,

It's not always possible to detect a disconnect. In best cases the SocketObserver gets a connectionBroken(NIOSocket nioSocket, Exception exception), but depending on the disconnect, it is possible that it will take a long time to get that callback. By sending packets (I don't know what's available for your server), the build in mechanisms in TCP (resends etc) will help the NIO (and Naga) detect the disconnect.

Usually some sort of NOOP-packet or ping is used for this purpose.

/C

On Oct 12, 2012, at 12:19, Christian <o157...@rtrtr.com> wrote:

> Hello Naga users!
>
> First of all a big Thank You! to Christofer that shares his project and knowledge with the community.
>
> In my naga project I have a client that establishes a tcp connection with naga to a tcp server.
> The server itself is not implemented with naga and I do not have control over it.
>
> I would like to know how could I determine the situation if the socket was closed by the server in my client that is implemented with naga.
> I use the NioService.selectBlocking() in a separet Thread to listen for server events.
>
> I would realy appreciate it if I someone could help answering this question
>
> --
> You received this message because you are subscribed to the Google Groups "Naga Users" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/naga-users/-/tkL1B5r4E8MJ.
> To post to this group, send email to naga-...@googlegroups.com.
> To unsubscribe from this group, send email to naga-users+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/naga-users?hl=en.

Reply all
Reply to author
Forward
0 new messages