I am not sure, but this may actually be a bug in the JVM.

I say this becuase I documented a Socket bug three years ago that involved
the closing of one side of a Socket connection. For example, in the UNIX
RSH protocol, the Socket used in the protocol appears as "stdio". In other
words, stdin, stdout, and stderr (on a second socket).

RSH is designed to run commands, and many UNIX commands use end of file (EOF)
on stdin to signal the completion of processing. For instance, the "cat"
program reads data from stdin, and writes the data to stdout, until it sees
EOF on stdin.

Thus, the RSH protocol can not run cat unless it can signal EOF on its stdout,
which is the server-side program's (cat in this case) stdin.

HOWEVER, the only way to signal EOF on a socket is to close the socket. Now,
sockets have two sides, and you are able to close one side or the other, while
continuing to use the other side. Thus, in theory, the RSH client program should
be able to close its stdout (cat's stdin) to signal EOF, while continuing to read
its stdin (cat's stdout) to read the output from cat.

ALAS, when the client closes its stdout side of the Socket, the JVM actually
closes BOTH sides of the socket connection, which is a bug. It prevents the client
from reading cat's output!

Supposedly, this bug was fixed in Java 1.3.1, but I have not had time to verify this.
Thus, if you are not using the 1.3.1 JVM, you may want to try it to see if you get
the same behavior.

tim.

> java.net.SocketException: socket closed
>         at java.net.PlainDatagramSocketImpl.receive(Native Method)
>         at java.net.DatagramSocket.receive(DatagramSocket.java:392)
>         at com.evermind.net.jc.ar0(JAX)
>         at com.evermind.server.jms.ca.run(JAX)
>         at java.lang.Thread.run(Thread.java:484)
> 
>    More: Using Win2k, Orion 1.4.5 (1.4.8), RMI clustering turned on.
> 
>    Explanation: My research points, that Orion is using one and the same port to 
>multicast and receive multicasting messages. However, if one tries to close the 
>sending socket, the receiving one is also closed (not in all 100% of the cases. 
>Approximately that happens every 25%, something to do with the synchroinization I 
>think).


Reply via email to