![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Aug 2007
Posts: 13
Rep Power: 0
![]() |
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 |
|
|
|
|
|
#2 |
|
Caffeinated Neural Net
![]() Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,033
Rep Power: 5
![]() |
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.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot. - Vaarsuvius, Order of the Stick |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
Join Date: Jun 2006
Location: Ireland
Posts: 152
Rep Power: 3
![]() |
Boost.Serialization is very comprehensive library which could be helpful.
__________________
Visit my website BinaryNotions. |
|
|
|
|
|
#4 | |
|
Newbie
Join Date: Aug 2007
Posts: 13
Rep Power: 0
![]() |
what is serialization and how i use it
Quote:
can u tell me what exactly is serialization and how i implement serialization Amit |
|
|
|
|
|
|
#5 | |
|
Caffeinated Neural Net
![]() Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,033
Rep Power: 5
![]() |
Quote:
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.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot. - Vaarsuvius, Order of the Stick |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
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 |