• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ObjectOutputStream causes SocketException

 
Prasanth Ravi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a client-server application. Right now, I'm trying to test sending messages from the client to the server and then read them from the server.
I'm using ObjectInputStream and ObjectOutputStream to transfer message objects between the client and server.

However, when I try to write an object from the client, it results in a SocketException.

Server code:



Server Thread:


Client code:



The statement out.writeObject(msg) causes a ServerSocket exception with Socket closed as the reason. And the server does not register receiving an object from in.readObject().

netstat shows the connection as established, the error occurs when I try to write the object.

What am I doing wrong ?
 
Joe Ess
Bartender
Posts: 9337
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see anything obvious. What does the full stack trace look like?
 
Henry Wong
author
Marshal
Pie
Posts: 22094
88
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prasanth Ravi wrote:
Client code:




Can we assume that you are *not* actually using address "0.0.0.0", and that it is just that way for the post (to obfuscate your location)?

Henry
 
Prasanth Ravi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using the localhost.
I figured out the problem, it was not in the source code. It was a problem with my test code.
I forgot to mark this resolved, my bad.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic