Created
March 1, 2022 09:14
-
-
Save cho0h5/b34cdaf94a5a8e9368d9d061dc2b230e to your computer and use it in GitHub Desktop.
INADDR_ANY, INADDR_BROADCAST, INADDR_LOOPBACK
This file contains hidden or 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
#include <stdio.h> | |
#include <netinet/in.h> | |
void print_addr(unsigned int addr) { | |
printf("%d.", (char)(addr >> 24)); | |
printf("%d.", (char)(addr >> 16)); | |
printf("%d.", (char)(addr >> 8)); | |
printf("%d\n", (char)addr); | |
} | |
int main() { | |
print_addr(INADDR_ANY); // 0.0.0.0 | |
print_addr(INADDR_BROADCAST); // 255.255.255.255 | |
print_addr(INADDR_LOOPBACK); // 127.0.0.1 | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment