Socket is still connected after Server-Side socket termination.
- From: pek <kimwlias@xxxxxxxxx>
- Date: Wed, 19 Sep 2007 06:19:54 -0700
Basic Idea
So I have this client-server project where the client uses Java's
Socket class to communicate with the server using JSON. Let's say that
I have a fake message that the client sends to the server and the
server closes the socket with the client (it doesn't send any response
to the client). In the client side I have a Thread that loops through
the socket's inputstream and prints out any server response. I also
print out the socket's connection status (socket.isConnected()).
Problem
When the client first sends the message the server immediately closes
the socket (I also terminate the server to make sure). The client, on
the other hand, never gets notified that the socket is closed and
everything seems running normal (it still prints out "true" every
socket.isConnect() method call). Only after a few attempts of sending
a message will the client understand that the socket is closed and
tries to reconnect.
Structure
SockeEngine is a class that handles the thread and has a
BlockingQueue<String> for outgoing messages. The thread loops forever.
The loop looks at the queue, the inputstream and outputstream. When
the queue has a message(s) to send it writes it to the outputstream of
the socket. After that it reads the inputstream and finnaly sleeps for
100ms.
I heard that the way we wrote it isn't the problem. We think the
problem relies on the implementation of sockets in Java or Windows. We
also think that it most likely not. Our temporary solution is sending
a termination message from the server to the client and then closing.
Any ideas/suggestions?
Thank you very much for your time.
-pek
.
- Follow-Ups:
- Re: Socket is still connected after Server-Side socket termination.
- From: Thomas Schodt
- Re: Socket is still connected after Server-Side socket termination.
- From: Martin Gregorie
- Re: Socket is still connected after Server-Side socket termination.
- From: Roedy Green
- Socket is still connected after Server-Side socket termination.
- From: derek
- Re: Socket is still connected after Server-Side socket termination.
- From: Gordon Beaton
- Re: Socket is still connected after Server-Side socket termination.
- Prev by Date: Re: Socket is still connected after Server-Side socket termination.
- Next by Date: Socket is still connected after Server-Side socket termination.
- Previous by thread: SMTPTransport chokes with >1 thread, >1 message
- Next by thread: Re: Socket is still connected after Server-Side socket termination.
- Index(es):
Relevant Pages
|
Loading