[SDL] the "UDPpacket" structure "data" member type
nyocurio at gmail.com
Sun Oct 6 08:04:41 PDT 2013
2013/10/6 YuGiOhJCJ Mailing-List <yugiohjcj-mailinglist at laposte.net>
> I am using sdl_net-1.2.8.
> I have a problem with the "UDPpacket" structure  because the "data"
> member is of type "Uint8*" whereas the data I want to send over network is
> a structure... So I am unable to cast.
> Why it is not a "void*" type for the data member ?
> Thank you.
> Best regards.
I presume you're using C++? If everything else fails you can always
reinterpret_cast anything to anything
(I think). Anyway, I'm not sure you're just supposed to point the packet's
data pointer to your structure.
When you create the UDP packet, you specify a size, right? I think the data
member points to an already
allocated chunk of memory, so you should just memcpy your struct into it
(assuming you allocated the
packet with the size of your struct).
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SDL