![]() |
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 |
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.
|
Boost.Serialization is very comprehensive library which could be helpful.
|
what is serialization and how i use it
Quote:
can u tell me what exactly is serialization and how i implement serialization Amit |
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. |
| All times are GMT -5. The time now is 1:16 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC