//parameter:
IPBUF: The array of list of IP addresses is stored, and the actual size is specified by bufcount.
BUFCOUNT: The number of IP addresses you want to get.
#ifdef _win32
#include #include #pragma Comment (lib, "ws2_32.lib")
#ELSE
#include #include #include #include #include #include #include
#ENDIF
int getselfiplist (unsigned long ipbuf [], int bufcount) {int i, count = 0; #ifdef _WIN32 char hostname [128]; struct hostent * inaddrs; if (gethostname (hostname, 128) == 0) {inaddrs = gethostbyname (Hostname); if (inaddrs) {count = INADDRS-> h_length / sizeof (in_addr); if (count> bufcount) count = bufcount; for (i = 0; i h_addr_list [i];}}} #} #} #} # = socketdr; sock = socket (AF_INET, SOCK_DGRAM, 0); if (SOCK> = 0) //! <0 {IF (BUFCOUNT> 100) bufcount = 100; for (i = 0; i