none
gethostbyname() returns only "127.0.0.1" IP address. Anybody know why ? RRS feed

  • 질문

  • I use gethostbyname("MyPC") to get ip address lists and it works great with many computers.

    My application has to be in 'Startup' program, and some reason, there are just few computers returning "127.0.0.1" when my app is started right after PC boots up.

    In this case, if i close my app and restart it, then it gets right IP address.

    Anybody know why ? Please give any idea...

     

     

     

    2011년 8월 30일 화요일 오후 5:31

답변

  •  

    Hi,

    Thanks for posting here.

     

    I think that you will get default ip(127.0.0.1) address at the time of booting up. because the NIC does not bind other IP address You must wait for binding.

    I recommend that you add check code that is to check if gethostbyname correctly return IP Address Information.

     

    Regards,

    Forum Support

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    • 답변으로 표시됨 Shaq32 2011년 9월 1일 목요일 오후 5:53
    2011년 8월 31일 수요일 오전 12:29
    중재자

모든 응답

  •  

    Hi,

    Thanks for posting here.

     

    I think that you will get default ip(127.0.0.1) address at the time of booting up. because the NIC does not bind other IP address You must wait for binding.

    I recommend that you add check code that is to check if gethostbyname correctly return IP Address Information.

     

    Regards,

    Forum Support

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    • 답변으로 표시됨 Shaq32 2011년 9월 1일 목요일 오후 5:53
    2011년 8월 31일 수요일 오전 12:29
    중재자
  • Thanks for you reply and we decide to wait program to get right IP which is i don't like to, but it seems this is only solution for now.

    Thanks again.

     

    2011년 9월 1일 목요일 오후 5:54