MetalGod
June 13th, 2004, 01:59 AM
Hey there,
I'm trying to send an instance of a class via a UDP packet.
I'm using this method--
udpclient.Send( (char*)&message_class, sizeof(MessageClass));
This creates an error, because when I cast my class to the char*, it ends up only being about 4 bytes long, which is an incorrect size. When I do a sizeof(MessageClass), it correctly reports it as 128bytes. I want to send the entire 128bytes of the class.
I know that casting a class to a char* is an unsafe way of serializing an object, but unfortunately the listener program was written by someone else and deserialzes the class with this method.
I'm porting the sender program from UNIX style C that used winsock.h, I'm trying to used the Managed C++ .NET libraries.
Thanks!
Dave
I'm trying to send an instance of a class via a UDP packet.
I'm using this method--
udpclient.Send( (char*)&message_class, sizeof(MessageClass));
This creates an error, because when I cast my class to the char*, it ends up only being about 4 bytes long, which is an incorrect size. When I do a sizeof(MessageClass), it correctly reports it as 128bytes. I want to send the entire 128bytes of the class.
I know that casting a class to a char* is an unsafe way of serializing an object, but unfortunately the listener program was written by someone else and deserialzes the class with this method.
I'm porting the sender program from UNIX style C that used winsock.h, I'm trying to used the Managed C++ .NET libraries.
Thanks!
Dave