File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes sending an instance of a  class thru a socket Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "sending an instance of a  class thru a socket" Watch "sending an instance of a  class thru a socket" New topic
Author

sending an instance of a class thru a socket

Preetham M
Greenhorn

Joined: Sep 18, 2002
Posts: 12
Hi All:
I have a fundamental question on sending data thru sockets.
I have a class, class A { int a; int b;}
I have created an object where i have initialised it to some specific values in my main class. I would now like to send this data to another socket. can i send the contents of the class as a single unit, or must i break it down n send it byte by byte.
I am currently using out.write()to send data.
Would appreciate the help.
Thanks,
Preetham.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
You can use serialization to send objects through any form of stream. Search for the serialization tutorial at java.sun.com


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Preetham M
Greenhorn

Joined: Sep 18, 2002
Posts: 12
thanx..found it.
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Preetham M,
We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.
Thanks Pardner! Hope to see you 'round the Ranch!


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: sending an instance of a class thru a socket
 
Similar Threads
sending an encrypted byte array through a socket
Question about transfering data over sockets
sending an encrypted byte array through the net
Socket connection program works for localhost but not for other ip
Transferring file name then file data over socket