Friends can you please tell me how can i send object of a class over a network to the client??

On client, send the object just like you would send any other blob, then on client recreate it from the blob. Probably something like below. Make sure the class has an overloaded = operator for this to work.

// server
MyClass object;
...
send(socketID, &object, sizeof(MyClass));
// client
// this isn't going to be technically accurate, but gives you the idea.
unsigned char* buf = recv(sucketID);
MyObject object = *(MyObject*)buf;

Well, its not quite as easy as what I posted, there is code that I omitted. Also it may be more complex depending on the class objects, such as pointers, other classes, etc.

consider using a textual format (maybe xml).

text is a universal format; it is easy for people to read, write, and edit.
and the network payload is easier to inspect, to modify and to debug.

text data is transparent and help enforce encapsulation between programs.

a textual protocol tends to future-proof your system. one reason is that ranges on numeric fields, padding of members and endianness aren't implied by the format itself. on the other hand, binary formats are platform specific and are difficult to extend.

This article has been dead for over six months. Start a new discussion instead.