-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unified sockaddr->SDLNet_Address code, implemented SDLNet_GetLocalAdd…
…resses. Added an example app for SDLNet_GetLocalAddresses. This commit is not tested on, or even compiled for, Windows yet.
- Loading branch information
Showing
3 changed files
with
210 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* This is just for demonstration purposes! This doesn't | ||
* do anything as complicated as, say, the `ifconfig` utility. | ||
* | ||
* All this to say: don't use this for anything serious! | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <SDL3/SDL.h> | ||
#include <SDL3/SDL_main.h> | ||
#include "SDL_net.h" | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
SDLNet_Address **addrs = NULL; | ||
int num_addrs = 0; | ||
int i; | ||
|
||
if (SDLNet_Init() < 0) { | ||
SDL_Log("SDLNet_Init() failed: %s", SDL_GetError()); | ||
return 1; | ||
} | ||
|
||
addrs = SDLNet_GetLocalAddresses(&num_addrs); | ||
if (addrs == NULL) { | ||
SDL_Log("Failed to determine local addresses: %s", SDL_GetError()); | ||
SDLNet_Quit(); | ||
return 1; | ||
} | ||
|
||
SDL_Log("We saw %d local addresses:", num_addrs); | ||
for (i = 0; i < num_addrs; i++) { | ||
SDL_Log(" - %s", SDLNet_GetAddressString(addrs[i])); | ||
} | ||
|
||
SDLNet_FreeLocalAddresses(addrs); | ||
SDLNet_Quit(); | ||
|
||
return 0; | ||
} |