[SDL] local IP address (SDL_net)

Brian brian.ripoff at gmail.com
Fri Jun 15 01:51:48 PDT 2007


Nope, that doesn't seem to work for me. Does the machine you are using
this on have a valid DNS hostname or something? I changed
myAddress.host = 0; as NULL isn't really a Uint32 (and so GCC emits a
warning).

On 15/06/07, Christopher Larsen <christopherleelarsen at gmail.com> wrote:
> >
> > Ok, so where do you fill in the value of myIPaddress? =)
> >
>
> Oh, sorry, that part is trivial
>
>         myIPaddress.host = NULL;
>         myIPaddress.port = 69;
>
> The trick is to call SDLNet_ResolveIP() with host NULL to
> get your network name, which you feed back into SDLNet_ResolveHost()
> to convert that network name to an IP.
> Warning: if you have multiple network adapters, you're on a LAN or wireless
> or both, I have no idea which IP you'll get back.
> What I did is have comp1 connect to comp2,
> and comp2 tells comp1 what it sees
> comp1's IP as. ( GetPeerAddress() )
>
> Cheers!


More information about the SDL mailing list