[SDL] Net2: question

Bob Pendleton bob at pendleton.com
Fri Sep 8 08:39:06 PDT 2006

On Fri, 2006-09-08 at 11:19 +0300, Vassilis Virvilis wrote:
> Halo,
> I am investigating SDL_Net and I am using the
> excellent Net2 library by Bob Pendleton. Note that
> Net2 is a thin layer around SDL_net and does not perform
> any swaping.
> But I think it should do.
> The problem:
> ------------
> I am calling
> NET2_UDPAcceptOn(int port) which calls
> SDLNet_UDP_Open(int port)
> which accepts native byte order integer. So far so good.
> Now when I am receiving UDP packets on this port, the
> source port number is swapped. OK. let's just accept
> that. This is the network.
> Now when I am trying to send using
> NET2_UDPSend(IPaddress *ip, char *buf, int len) which calls
> SDLNet_UDP_Send(requires UDPpacket)
> the ip->port member must be jammed again -- unlike the other uses
> of IPaddresses
> I believe since NET2_UDPSend requires an IPaddress it should
> be noted with __very__ big letters in the documentation.
> Or
> better hide the swap inside NET2_UDPSend and during the receipt
> of the UDPpacket.
>     .bill

Hi, what kind of machine are you working on that you are having trouble
with the byte order of ip address and port numbers? These are values
that are passed through to the OS and received back from the OS, not
values that go over the wire. That means there is no worry about network
ordering of that data. If there were a problem, you would never be able
to connect or send data.

BTW, it is best to send these kinds of questions directly to the
developer. I sometimes go weeks without looking at the SDL list, but I
rarely go more than a few days without looking at my personal email. And
even when I do read the SDL mailing list I can't guarantee to see every
message sent to me.

		Bob Pendleton

> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl
+ Bob Pendleton: writer and programmer +
+ email: Bob at Pendleton.com             +
+ web: www.GameProgrammer.com          +
+ www.Wise2Food.com                    +
+ nutrient info on 7,000+ common foods +

More information about the SDL mailing list