• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sending an instance of a class thru a socket

 
Preetham M
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use serialization to send objects through any form of stream. Search for the serialization tutorial at java.sun.com
 
Preetham M
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanx..found it.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic