Example code to display the value of INADDR_ANY
October 06, 2011 12:32:21 Last update: October 06, 2011 12:32:21
What's the value of
Output:
INADDR_ANY? You can look it up in header files, but it's equally easy to get it with a little code:
#include <stdio.h> #include <arpa/inet.h> int main(int argc, char* argv[]) { struct sockaddr_in sa; sa.sin_addr.s_addr = htonl(INADDR_ANY); printf("INADDR_ANY value: %s\n", inet_ntoa(sa.sin_addr)); return 0; }
Output:
$ ./inaddrvalue INADDR_ANY value: 0.0.0.0