[SDL] local IP address (SDL_net)

Brian brian.ripoff at gmail.com
Mon Jun 11 06:58:44 PDT 2007


Ok, so where do you fill in the value of myIPaddress? =)

On 10/06/07, Christopher Larsen <christopherleelarsen at gmail.com> wrote:
>  Yes you can...
>         // Check what my real IP is first
>         BUG("Check what my real IP is: ");
>         const char* tempstr = SDLNet_ResolveIP(&myIPaddress);           // Get
> the network name of this computer
>         if (tempstr) BUG("tempstr is valid");
>         if (strlen(tempstr) > 79) ERROR("ERR: Filename too long!");
>         strcpy(myNetworkName, tempstr);
>         fprintf(stdout,"myNetworkName is: ");
>         fprintf(stdout, " %s \n", myNetworkName); fflush(stdout);
>
>         SDLNet_ResolveHost(&myIPaddress, myNetworkName, FOUNDATION_PORT);
>         // Fill up an ip with my network name
>         iterator = (Uint8*) &myIPaddress.host;                  // This simple
> elegant code reads the host Uint32 member into a readable IP
>         fprintf(stdout, "%d.", *iterator++);                    //
>         fprintf(stdout, "%d.", *iterator++);                    //
>         fprintf(stdout, "%d.", *iterator++);                    //
>         fprintf(stdout, "%d ", *iterator);                              //
>         fprintf(stdout,"myIPaddress.port is: ");
>         fprintf(stdout, " %d \n", myIPaddress.port);
>         fflush(stdout);
>
>
>
>
>
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>


More information about the SDL mailing list