[SDL] the "UDPpacket" structure "data" member type

Jonas Kulla nyocurio at gmail.com
Sun Oct 6 08:04:41 PDT 2013


2013/10/6 YuGiOhJCJ Mailing-List <yugiohjcj-mailinglist at laposte.net>

> Hello,
>
> I am using sdl_net-1.2.8.
> I have a problem with the "UDPpacket" structure [1] 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.
>

Hi,

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).

Jonas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20131006/e5931be3/attachment-0008.htm>


More information about the SDL mailing list