The java.net.SocketException is raised when the client dies and all the
connections opened by its process are reset (that's the meaning of "Connection
reset by peer"). Under Unix, you don't get this exception, but the read() call
on the socket stream returns -1 ; Under Windows, you get the exception.

The server still tries to read from the stream, even though the session has
been closed, because I have found no way to prevent it from doing so... A
server thread is blocked reading from the stream, and interrupting it has no
effect under Windows.

The conclusion is that you should simply catch the exception, and close the
session.

Regards,

Bruno


Per Christian Nodtvedt wrote:

> After studying the knock-knock example, I've finally managed to make
> something on my own with Jonathan on a protocol level (wheeee!).  However, I
> have encountered a recurring problem that I find rather strange, and I
> wonder if anyone has an explanation.
>
> Using the TcpIpProtocol, I make a Session and happily send and receive
> messages using the CDRMarshallerFactory to make my messages.  The
> communication structure is very simple, with a server running a
> TcpIpProtocol object with an exported Session_Low that prints out any
> Strings received from the client, given that the message has the correct
> header.  The client also has a running TcpIpProtocol, and makes new
> Marshallers containing java Strings and sends them over the network.
>
> As long as the client makes new Marshallers and sends them off, everything
> works fine.  The moment my client stop doing this though, something in the
> TcpIpProtocol sends another message.  As this message is badly formatted
> (eg. does not have my header) and in fact empty, my Session_Low on the
> receiving side throws an Exception.  The stacktrace goes as follows:
>
> java.net.SocketException: Connection reset by peer
>         at java.net.SocketInputStream.read(SocketInputStream.java:84)
>         at
> org.objectweb.jonathan.libs.resources.tcpip.IPv4ConnectionFactory$Connection
> .receive(Compiled Code)
>         at
> org.objectweb.jonathan.libs.protocols.tcpip.TcpIpChunkProvider.prepare(TcpIp
> Protocol.java:707)
>         at
> org.objectweb.david.libs.presentation.portable.CDRMarshallerFactory$CDRUnMar
> shallerD.prepare(Compiled Code)
>         at
> org.objectweb.david.libs.presentation.portable.PortableMarshallerFactory$Por
> tableUnMarshaller.readByte(PortableMarshallerF
>         at SplitProtocol$TcpIpSessionLow.send(SplitProtocol.java:166)
>         at
> org.objectweb.jonathan.libs.protocols.tcpip.TcpIpProtocol$Session.run(TcpIpP
> rotocol.java:403)
>         at
> org.objectweb.jonathan.libs.resources.JScheduler$JJob.run(Compiled Code)
>
> I interpret this to mean that the server thinks another message is on it's
> way, even though it's not.  The server attempts to read from this message
> (with the readByte method in PortableUnMarshaller) with the appropriate
> Session_Low, and ends up raising an exception in the object that
> encapsulates the Socket that's actually handling the data-transmission.
>
> My question is why does the server attempt to read this last (and in in my
> view) non-existing message?  I have tried closing my sessions after sending
> the last message, but I still end up getting the same exception.  A solution
> to this is of course to catch the Exception and ignore it, but I don't
> really like the thought of having to perform a hack like that on such a low
> level.  I'm also unsure wether the Session can be reused after the
> Exception, as the Socket tells me it has been reset by peer.
>
> I do not encounter the same problem when I'm using MulticastIpProtocol.  It
> sends and receives with a merry grin and knows just when to read and when
> not to :o)
>
> If more information is needed, I can post the code that provokes the error.
> I use Jonathan 2.0.1 and jdk1.1.8.
>
> Best regards,
> Per Christian Nodtvedt
>
> ps.  Please don't reply to messages on the mailing list when you have a new
> question unrelated to the current thread.  Send a new message to the list
> instead.  My last two messages has qualified me to end up in the cc: field
> on some other postings, and I therefore get every message and reply at least
> twice.  It also messes up the neat layout on the mailing list presentation
> by thread page at objectweb.org :o)  .ds
>
> To unsubscribe, send email to [EMAIL PROTECTED] and
> include in the body of the message "unsubscribe jonathan".
> For general help, send email to [EMAIL PROTECTED] and
> include in the body of the message "help".
begin:vcard 
n:Dumant;Bruno 
tel;cell:06 75 20 76 64
tel;fax:33 1 49 26 09 76
tel;work:33 1 42 44 40 74
x-mozilla-html:FALSE
url:www.kelua.com
org:Kelua SA
adr:;;55 rue Sainte Anne;Paris;;75002;France
version:2.1
email;internet:[EMAIL PROTECTED]
x-mozilla-cpt:;1
fn:Bruno Dumant
end:vcard

Reply via email to