aspose file tools
The moose likes Sockets and Internet Protocols and the fly likes How to send any java Object through socket? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Reply Bookmark "How to send any java Object through socket?" Watch "How to send any java Object through socket?" New topic
Author

How to send any java Object through socket?

Parshuram Walunjkar
Ranch Hand

Joined: Jan 02, 2002
Posts: 31
Hi Everybody,
I want know how to send any java Object through socket i.e. send Object through socket from client side and read it to the server side and vice versa.
Please suggest solution me.
Regards From Parshuram
Les Dsouza
Greenhorn

Joined: Jan 29, 2002
Posts: 27
To send an object thru a stream you need to serialize it ie.. the object should implement the serializable interface; this is a 'marker' interface hence you dont need to define any methods.
All objects that support the java.io.Serializable interface can be written to streams.
TO send the object you use an ObjectOutputStream - call its writeObject method, Likewise to read you use the ObjectInputStream's readObject method.
Hope the code below helps -

[ February 04, 2002: Message edited by: Les Dsouza ]
[ February 04, 2002: Message edited by: Les Dsouza ]
Parshuram Walunjkar
Ranch Hand

Joined: Jan 02, 2002
Posts: 31
Hi all,
I am sending Object from server to client it receive to the client side but I am doing that hole thing in thread so it gives exception such as streamCorrecuptedException
Why such exception occurs?
Please help me
From
Parshuram Walunjkar
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to send any java Object through socket?
 
Similar Threads
how to get Client Ip address?
Socket Sending and Recieving at same Time?
SOAP customizing object with JNI
how to work with socket
Reading an object from ObjectInputStream