aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes Sending object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Sending object" Watch "Sending object" New topic
Author

Sending object

Matthew Tilic
Ranch Hand

Joined: Apr 07, 2011
Posts: 41

Hi this is my first thread

If anyone can help that would be great. So my problem. My server will not send my object. I have looked online and followed alot of what has been said but the thing will still not send!!!

The issue is at the the Server when the the call to send Performance is ran and the ooS.writeObject is called.

Class Performance just has a load of information in it including strings, int, int[].

Server code

Main:



CreateStreamSocket:


SerilizedObject





Client code

Main:


clientListener:



Thanks for any help
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

Regardless of all that code, let's start with this: how do you know it "won't send the object"? I'm asking for a description of the problem here, in case
that isn't clear.
Matthew Tilic
Ranch Hand

Joined: Apr 07, 2011
Posts: 41

When the ObjectOutputStream goes to writeObject(P); It goes to an exception I\O
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

Okay. And what does the exception say? If there's a stack trace (and there should be) then it tells you which line of code threw the exception and why.
Matthew Tilic
Ranch Hand

Joined: Apr 07, 2011
Posts: 41

java.net.SocketException: Socket closed
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:99)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at java.io.ObjectOutputStream$BlockDataOutputStream.drain(ObjectOutputStream.java:1847)
at java.io.ObjectOutputStream$BlockDataOutputStream.setBlockDataMode(ObjectOutputStream.java:1756)
at java.io.ObjectOutputStream.writeNonProxyDesc(ObjectOutputStream.java:1257)
at java.io.ObjectOutputStream.writeClassDesc(ObjectOutputStream.java:1211)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1395)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
at java.io.ObjectOutputStream.writeFatalException(ObjectOutputStream.java:1547)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:333)
at serverstreamtest.createStreamSocket.sendPerformance(createStreamSocket.java:96)
at serverstreamtest.createStreamSocket.<init>(createStreamSocket.java:68)
at serverstreamtest.Main.main(Main.java:27)

By the way thanks for this. Really appreciate it like you can not believe
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

The message seems pretty clear to me: the socket is closed. And since that's an error message telling you that, the implication is that the socket
shouldn't be closed. So that means you have to look at your code to find out why that is the case.
Matthew Tilic
Ranch Hand

Joined: Apr 07, 2011
Posts: 41

Thanks I have moved the writeObject command further up the code and it works!!! would the stream close by sending it to a function?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

"Sending to a function" isn't standard Java terminology. However if your question could be translated as "If I call a method which closes a socket which
is passed as a parameter, does it close that socket?" then the answer is yes.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19784
    
  20

And welcome to the Ranch!


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sending object