Re: object output stream on socket

From: Maria Gaitani (M.Gaitani_at_warwick.ac.uk)
Date: 02/22/04


Date: Sun, 22 Feb 2004 14:57:06 -0000

Thank you very much for your time and help !!
I will try that straight away !

Maria

"Maria Gaitani" <M.Gaitani@warwick.ac.uk> wrote in message
news:403820bb$0$24603$fa0fcedb@lovejoy.zen.co.uk...
> Hi!
>
> I have made a client and a server which are supposed to communicate by
> sending java objects. They don't.
> I have managed to send an object from the client to the server. But
> continuing after that I can't do the opposite. I want the program to send
an
> object-reply from the server to the client. But on this step boths sides
> throw a socket exception.
> From println's I have figured out that it can't set up on either side the
> corresponding stream: output stream for the server and input stream for
the
> client.
> I have closed the input stream on the server and the output stream on the
> client from the first sending of the object.
> The object that's being sent does implement serializable.
>
> The blocks of code of setting up the streams are below.
> Any help would be greatly appreciated.
> Maria
>
> Here is the code the client is running to receive (it throws the exception
> just after the println statement):
> System.out.println("in receive");
> InputStream in = client.getInputStream();
> ObjectInputStream receive = new ObjectInputStream(in);
> Object received = receive.readObject();
> receive.close();
> in.close();
>
> Here is the code the server is running to send (it throws the exception
just
> after the println statement):
>
> System.out.println("in send");
> OutputStream out = connection.getOutputStream();
> System.out.println("got stream one");
> ObjectOutputStream sendStream = new ObjectOutputStream(out);
> sendStream.writeObject(toSend);
> sendStream.close();
> out.close();
>
>



Relevant Pages

  • Re: file transfer with sockets
    ... confirmation from client for each chunk before sending the next? ... to server, server interprets command, executes it, then simply returns ... files (hence the reading in chunks). ... sending the bytes over the stream. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How do I stop a Winsock from buffering characters?
    ... The client is just doing this to send: ... Stream s = client.GetStream; ... I just wan to send one character ... from the client code and have the server see it right away. ...
    (microsoft.public.windowsce.embedded)
  • Re: Client Server
    ... Otherwise, read a file in via a stream, make any required updates, and write ... > myself and compares it to the data that the client has sent to ... My response, though it was very general in nature, assumed exactly what you ... at some point you want the server to read this file in. ...
    (comp.lang.java.help)
  • Re: A Media Distribution Problem
    ... > A supplier wishes to sell his goods by realtime downloading ... One way to solve this is to lock each login to a MAC address at the server ... You have a MPEG stream being sent to the main distribution server. ... At the client end, each piece of software has a unique RSA private key. ...
    (sci.crypt)
  • Re: What doesnt lend itself to OO?
    ... >> proxy and instructs the server to constuct the real object. ... rather than client code. ... If 'clock' is instantiated in the server, ... > for the server interface at the OOA level. ...
    (comp.object)