Re: Sockets, writing data and shutdownOutput



jan V wrote:
> > > close() on the stream???? The server is only going to see EOF if you
> close()
> > > the OutputStream in the client....
> >
> > Not true. shutdownOutput() on the client side signals
> > EOF to the server. However, a close() on the
> > OutputStream shuts down the whole socket,
>
> Well, maybe you're using a different version of Java than the version (1.3)
> I used to build a system which totally relied on closing output streams to
> send EOFs to the recipient. Under 1.3 this worked 100% of the time... what
> version are you using?

I am using 1.4, and 1.5 has the same bug, see
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4717638

Direct from the sources of SocketOutputStream.close():

if (socket != null) {
if (!socket.isClosed())
socket.close();

This does not look like merely closing the output
side of things.

The bug mentioned above, luckily, is still open
despite the unfavorable comment from SUN.
According to the comment, this was always a
problem, which somehow contradicts your statement.
Maybe you did not expect outstanding response data
after closing the output side of the socket in
the client.

Harald.

.



Relevant Pages

  • Re: Socket switch delay
    ... both at the client and at the server (and why ... would you set the send buffer size to zero on a non-overlapped ... One glaring error is your client does ... So when you use a single socket, ...
    (microsoft.public.win32.programmer.networks)
  • Re: Locking on async calls
    ... you must synchronize the entire SendMessage routine as an atomic ... operation to prevent mixed messages from being transmitted to the server. ... You are correct that read and write on the socket do not interfere with each ... If you want to handle multiple client connections from one server object ...
    (microsoft.public.dotnet.general)
  • Re: socket communication: socket doesnt connect
    ... Microsoft MVP, MCSD ... As far as your server code goes, ... accept the listening socket. ... Client client = new Client; ...
    (microsoft.public.vc.language)
  • Re: TCP server stop receiving new connections
    ... reset the event mask of your listening socket each time you ... I have a strange problem in my class library used by all our client ... server applications. ... incomming connections, but keeps current connections. ...
    (microsoft.public.win32.programmer.networks)
  • Re: Design issue with WinSock/GetQueuedCompletionStatus
    ... delegate that to a shutdown routine called after all worker threads ... The application I've created is a server accepting connections on a few ... different TCP/IP ports and then lets the client run different commands. ... a TCP/IP socket can be closed for 2 different reasons: ...
    (microsoft.public.win32.programmer.networks)