[SDL] Net2: question

Vassilis Virvilis vasvir at iit.demokritos.gr
Fri Sep 8 09:09:57 PDT 2006

Bob Pendleton wrote:
> 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.

Standard PC (athlon).

I don't have a problem of connecting. I am connecting to the wrong port.
If I want to transmit UDP data to some host at port 8899 it will send
the data to port 49954.

What's my use case;

IPaddress ip = {some_precomputed_host, port};
NET2_UDPSend(&ip, data, data_size);

This code works for the TCP case. Oups! just checked. In my TCP
case I either use the NET2_ResolveHost that calls SDLNet_ResolveHost
that byteswaps the port, or I am using accept directly which takes
native order port by documentation.

Ok I was wrong. But Eitherway it's a bit confusing. Accept takes native
order integers but NET2_UDPSend requires a network order integer, but
I suppose this is a problem of SDLNet and not of Net2.

Sorry for the noise.

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

Ok next time I will bother you personally :-)


More information about the SDL mailing list