| [ CnUnix ] in KIDS 글 쓴 이(By): testors (testors) 날 짜 (Date): 2003년 9월 19일 금요일 오후 04시 22분 19초 제 목(Title): Re: 로컬 IP 알아내기? 이편이 더 간단할듯 싶네요. 플랫폼 안가립니다. (FreeBSD, Win32 에서 테스트해 봤습니다.) char buf[ 256 ]; struct hostent * p; struct in_addr* ptr; char** listptr; gethostname ( buf, sizeof(buf) ); p = gethostbyname( buf ); listptr = p->h_addr_list; if( p->h_addrtype == AF_INET ) { while( ( ptr = (struct in_addr*)( *listptr++ ) ) != NULL ) { printf( "%s\n", inet_ntoa( *ptr ) ); } } - Testors |