볼거리, 읽을거리, 놀거리
캐럿보이넷 :: 내(자기 자신) 아이피 알아내기
장안동베짱e
2006. 9. 12. 10:36
- void GetLocalIP( char* ip )
- {
- WORD wVersionRequested;
- WSADATA wsaData;
- char name[255];
- PHOSTENT hostinfo;
- wVersionRequested = MAKEWORD( 2, 0 );
- if ( WSAStartup( wVersionRequested, &wsaData ) == 0 ) {
- if( gethostname ( name, sizeof(name)) == 0) {
- if((hostinfo = gethostbyname(name)) != NULL) {
- strcpy( ip , inet_ntoa (*(struct in_addr *)*hostinfo->h_addr_list) );
- }
- }
- WSACleanup( );
- }
- }
가끔씩 코딩하다 보면 찾게 되는 소스 ㅎ