• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sending object

 
Matthew Tilic
Ranch Hand
Posts: 41
Chrome Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 20980
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 41
Chrome Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When the ObjectOutputStream goes to writeObject(P); It goes to an exception I\O
 
Paul Clapham
Sheriff
Posts: 20980
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 41
Chrome Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 20980
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 41
Chrome Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 20980
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
Pie
Posts: 20512
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic