Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 27th, 2007, 1:17 AM   #1
amitpansuria
Newbie
 
Join Date: Aug 2007
Posts: 13
Rep Power: 0 amitpansuria is on a distinguished road
how to transfer object using socket (tcp/ip)

helo,
if i wan to develping socket application using c++on linux.
if i want to transfer whole object then how can i transfer object from server to client using socket(tcp/ip) protocol
Regards,
Amit
amitpansuria is offline   Reply With Quote
Old Aug 27th, 2007, 2:07 AM   #2
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 895
Rep Power: 4 lectricpharaoh will become famous soon enough
If it's between machines with the same endianness, you can just trasmit it as a block of bytes. If not, or if you simply want a more portable solution, you can serialize the structure, and then send the bytestream out. Take your pic; it depends on your needs.
__________________
A man's knowledge is like an expanding sphere, the surface corresponding to the boundary between the known and the unknown. As the sphere grows, so does its surface; the more a man learns, the more he realizes how much he does not know. Hence, the most ignorant man thinks he knows it all. - L. Sprague de Camp
lectricpharaoh is offline   Reply With Quote
Old Aug 27th, 2007, 9:54 AM   #3
Eoin
Hobbyist Programmer
 
Eoin's Avatar
 
Join Date: Jun 2006
Location: Ireland
Posts: 152
Rep Power: 3 Eoin is on a distinguished road
Boost.Serialization is very comprehensive library which could be helpful.
__________________
Visit my website BinaryNotions.
Eoin is offline   Reply With Quote
Old Aug 28th, 2007, 2:40 AM   #4
amitpansuria
Newbie
 
Join Date: Aug 2007
Posts: 13
Rep Power: 0 amitpansuria is on a distinguished road
what is serialization and how i use it

Quote:
Originally Posted by lectricpharaoh View Post
If it's between machines with the same endianness, you can just trasmit it as a block of bytes. If not, or if you simply want a more portable solution, you can serialize the structure, and then send the bytestream out. Take your pic; it depends on your needs.
helo u say that i want to serialize the structure or object.
can u tell me what exactly is serialization and how i implement serialization
Amit
amitpansuria is offline   Reply With Quote
Old Aug 28th, 2007, 5:44 AM   #5
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 895
Rep Power: 4 lectricpharaoh will become famous soon enough
Quote:
Originally Posted by amitpansuria
helo u say that i want to serialize the structure or object.
can u tell me what exactly is serialization and how i implement serialization
Amit
Serialization, in this sense, is the process of taking a chunk of data and coverting it to a sequence of bytes for some kind of operation (generally writing to disk or sending across a network connection). In some contexts, the disk write/network transmission is subsumed in the term 'serialization'.

One of the benefits of serialization is it converts internal representations of data to a series of bytes, and thus the byte order of the CPU doesn't matter. Say you transmit a 32-bit int across a network connection, and the sending computer is, say, an Intel x86-based machine. The x86 architecture is 'little endian', meaning that multi-byte values are ordered in memory with the least significant byte first. In other words, the value 0xAABBCCDD would be four bytes, in this order: 0xDD, 0xCC, 0xBB, and 0xAA. The receiving computer, on the other hand, might be a big-endian machine, expecting the bytes like so: 0xAA, 0xBB, 0xCC, and 0xDD. Hell, maybe the receiving machine uses 64-bit ints. Either way, you have a problem.

Another benefit is that many functions for writing to disk or communicating across a network expect a buffer of bytes to work with. Serialization gives you this buffer of bytes.
__________________
A man's knowledge is like an expanding sphere, the surface corresponding to the boundary between the known and the unknown. As the sphere grows, so does its surface; the more a man learns, the more he realizes how much he does not know. Hence, the most ignorant man thinks he knows it all. - L. Sprague de Camp
lectricpharaoh is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Java socket Server compile errors.. n3o_X Java 3 Nov 18th, 2007 12:39 AM
.NET Socket Class hbe02 Show Off Your Open Source Projects 1 Oct 7th, 2006 11:00 AM
Level Editor frankish Show Off Your Open Source Projects 47 Jul 10th, 2006 6:57 PM
how to check if the socket is still connected? myName C++ 1 Jun 14th, 2006 6:27 AM
socket tcp/ip myName C++ 5 Feb 22nd, 2006 9:53 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:41 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC