[SDL] [SPAM] Preparing a UDP packet with SDL_net

James Buchwald jamestheprogrammer at gmail.com
Fri Jun 22 09:29:57 PDT 2007


Someone already emailed me a solution that works:

SDLNet_Write16(src, &packet->data[position]);

It looks to me like your solution is just another way of writing the
above... Thanks anyway, though.

On 6/22/07, Gabriele Greco <gabriele.greco at darts.it> wrote:
>
> James Buchwald wrote:
> >
> >     SDLNet_Write16(src, packet->data[position]);
>
> I think this should be:
>
> SDLNet_Write16(src, (char *)packet->data + position);
>
> The cast may not be needed if packet->data is already a pointer to an
> 8bit sized type.
>
> > Whenever my code runs, however, I get a segfault the first time
> > SDLNet_Write16 is called. The packet was successfully created, though,
> > and position is set to 0. Now I can't figure out what I'm doing wrong.
> You were writing to the memory address 0 (data[x] was zeroed for every x
> :) )
>
> Bye,
> Gabry
>
>
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>



-- 
"If you see somebody who you don't know getting into a crop duster that
doesn't belong to you, report them." -- President George W. Bush
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20070622/4ca41693/attachment.html 


More information about the SDL mailing list