A question about gethostbyname()

On QNX 4.25, I failed to execute function gethostbyname().
I am sure something is wrong with my system configuration,but, I can’t find
it out and correct it.

Thank you for any info.

Zhoujun

What is your netmap, from what I understand it should be 255.255.255.0

“zhoujun” <jzhou@mail.nairc.ac.cn> wrote in message
news:8ol2a1$t7r$1@inn.qnx.com

Thank you !
After restarting my computer, I tried to ping some involved IP addresses,I
found I can ping to any IP addresses in my subnet. And I can ping to my
nameserver and web servers in Internet,too.

My host: ..75.96
My nameserver: ..75.90
My gateway: ..75.8

But,I could not ping to ..120.20 although system knows the gateway
..75.8.
After adding the subnet by command “route add -net ..120 ..75.8”, I
can ping to ..120.20. I also want to know this cause.

The problem about gethostbyname() still exists.


Mitchell Schoenbrun <> maschoen@pobox.com> > wrote in message
news:> Voyager.000830233118.4698A@schoenbrun.com> …
Previously, zhoujun wrote in comp.os.qnx:

On QNX 4.25, I failed to execute function gethostbyname().
I am sure something is wrong with my system configuration,but, I can’t
find
it out and correct it.

Well the most likely thing that comes to mind is that the IP’s
in your /etc/resolv.conf point to name servers that are not
working. You might want to try pinging them for starters.



Mitchell Schoenbrun --------- > maschoen@pobox.com

\

Previously, zhoujun wrote in comp.os.qnx:

On QNX 4.25, I failed to execute function gethostbyname().
I am sure something is wrong with my system configuration,but, I can’t find
it out and correct it.

Well the most likely thing that comes to mind is that the IP’s
in your /etc/resolv.conf point to name servers that are not
working. You might want to try pinging them for starters.



Mitchell Schoenbrun --------- maschoen@pobox.com

Thank you !
After restarting my computer, I tried to ping some involved IP addresses,I
found I can ping to any IP addresses in my subnet. And I can ping to my
nameserver and web servers in Internet,too.

My host: ..75.96
My nameserver: ..75.90
My gateway: ..75.8

But,I could not ping to ..120.20 although system knows the gateway
..75.8.
After adding the subnet by command “route add -net ..120 ..75.8”, I
can ping to ..120.20. I also want to know this cause.

The problem about gethostbyname() still exists.


Mitchell Schoenbrun <maschoen@pobox.com> wrote in message
news:Voyager.000830233118.4698A@schoenbrun.com

Previously, zhoujun wrote in comp.os.qnx:

On QNX 4.25, I failed to execute function gethostbyname().
I am sure something is wrong with my system configuration,but, I can’t
find
it out and correct it.

Well the most likely thing that comes to mind is that the IP’s
in your /etc/resolv.conf point to name servers that are not
working. You might want to try pinging them for starters.



Mitchell Schoenbrun --------- > maschoen@pobox.com

I think Mario means ‘What is your netmask’ :slight_smile:

I believe you want the netmask to be 255.255.0.0

Heather


Mario Charest <mcharest@zinformatic.com> wrote:

What is your netmap, from what I understand it should be 255.255.255.0

“zhoujun” <> jzhou@mail.nairc.ac.cn> > wrote in message
news:8ol2a1$t7r$> 1@inn.qnx.com> …
Thank you !
After restarting my computer, I tried to ping some involved IP addresses,I
found I can ping to any IP addresses in my subnet. And I can ping to my
nameserver and web servers in Internet,too.

My host: ..75.96
My nameserver: ..75.90
My gateway: ..75.8

But,I could not ping to ..120.20 although system knows the gateway
..75.8.
After adding the subnet by command “route add -net ..120 ..75.8”, I
can ping to ..120.20. I also want to know this cause.

The problem about gethostbyname() still exists.


Mitchell Schoenbrun <> maschoen@pobox.com> > wrote in message
news:> Voyager.000830233118.4698A@schoenbrun.com> …
Previously, zhoujun wrote in comp.os.qnx:

On QNX 4.25, I failed to execute function gethostbyname().
I am sure something is wrong with my system configuration,but, I can’t
find
it out and correct it.

Well the most likely thing that comes to mind is that the IP’s
in your /etc/resolv.conf point to name servers that are not
working. You might want to try pinging them for starters.



Mitchell Schoenbrun --------- > maschoen@pobox.com

\

Check out the file “/etc/resolv.conf” and be sure it defines your nameserver
correctly. That may be your problem

Ivan

zhoujun <jzhou@mail.nairc.ac.cn> wrote in message
news:8okteh$pvd$1@inn.qnx.com

On QNX 4.25, I failed to execute function gethostbyname().
I am sure something is wrong with my system configuration,but, I can’t
find
it out and correct it.

Thank you for any info.

Zhoujun

What??? A netmap of 255.255.255.0? L:ooks like a netmask to me? :}

Mario Charest <mcharest@zinformatic.com> wrote in message
news:8oli4j$7q7$1@inn.qnx.com

What is your netmap, from what I understand it should be 255.255.255.0

“zhoujun” <> jzhou@mail.nairc.ac.cn> > wrote in message
news:8ol2a1$t7r$> 1@inn.qnx.com> …
Thank you !
After restarting my computer, I tried to ping some involved IP
addresses,I
found I can ping to any IP addresses in my subnet. And I can ping to my
nameserver and web servers in Internet,too.

My host: ..75.96
My nameserver: ..75.90
My gateway: ..75.8

But,I could not ping to ..120.20 although system knows the gateway
..75.8.
After adding the subnet by command “route add -net ..120 ..75.8”,
I
can ping to ..120.20. I also want to know this cause.

The problem about gethostbyname() still exists.


Mitchell Schoenbrun <> maschoen@pobox.com> > wrote in message
news:> Voyager.000830233118.4698A@schoenbrun.com> …
Previously, zhoujun wrote in comp.os.qnx:

On QNX 4.25, I failed to execute function gethostbyname().
I am sure something is wrong with my system configuration,but, I
can’t
find
it out and correct it.

Well the most likely thing that comes to mind is that the IP’s
in your /etc/resolv.conf point to name servers that are not
working. You might want to try pinging them for starters.



Mitchell Schoenbrun --------- > maschoen@pobox.com



\

The TCP/IP release for 4.25 has a problem in that the ifconfigalways sets
the
netmask to 255.255.255.0 whanever you define the “en1” IP. I have tried to
get to to create a 255.255.0.0, but if you check it always shows ffffff00 as
the
netmask, which is 255.255.255.0

Heather Johnstone <heather@qnx.com> wrote in message
news:8olmaf$4t4$1@nntp.qnx.com

I think Mario means ‘What is your netmask’ > :slight_smile:

I believe you want the netmask to be 255.255.0.0

Heather


Mario Charest <> mcharest@zinformatic.com> > wrote:

What is your netmap, from what I understand it should be 255.255.255.0

“zhoujun” <> jzhou@mail.nairc.ac.cn> > wrote in message
news:8ol2a1$t7r$> 1@inn.qnx.com> …
Thank you !
After restarting my computer, I tried to ping some involved IP
addresses,I
found I can ping to any IP addresses in my subnet. And I can ping to my
nameserver and web servers in Internet,too.

My host: ..75.96
My nameserver: ..75.90
My gateway: ..75.8

But,I could not ping to ..120.20 although system knows the gateway
..75.8.
After adding the subnet by command “route add -net ..120 ..75.8”,
I
can ping to ..120.20. I also want to know this cause.

The problem about gethostbyname() still exists.


Mitchell Schoenbrun <> maschoen@pobox.com> > wrote in message
news:> Voyager.000830233118.4698A@schoenbrun.com> …
Previously, zhoujun wrote in comp.os.qnx:

On QNX 4.25, I failed to execute function gethostbyname().
I am sure something is wrong with my system configuration,but, I
can’t
find
it out and correct it.

Well the most likely thing that comes to mind is that the IP’s
in your /etc/resolv.conf point to name servers that are not
working. You might want to try pinging them for starters.



Mitchell Schoenbrun --------- > maschoen@pobox.com



\

Thank you !
In my file “/etc/resolv.conf” :
domain nairc.ac.cn
nameserver ..75.90

And, the problem about gethostbyname() still exists either the netmask is
set to 255.255.0.0 or to 255.255.255.0.


Ivan Bannon <ivan.bannon@rjginc.com> wrote in message
news:8omk1t$obg$1@inn.qnx.com

Check out the file “/etc/resolv.conf” and be sure it defines your
nameserver
correctly. That may be your problem

Ivan

zhoujun <> jzhou@mail.nairc.ac.cn> > wrote in message
news:8okteh$pvd$> 1@inn.qnx.com> …
On QNX 4.25, I failed to execute function gethostbyname().
I am sure something is wrong with my system configuration,but, I can’t
find
it out and correct it.

Thank you for any info.

Zhoujun

\

zhoujun <jzhou@mail.nairc.ac.cn> wrote:

Thank you !
In my file “/etc/resolv.conf” :
domain nairc.ac.cn
nameserver ..75.90

And, the problem about gethostbyname() still exists either the netmask is
set to 255.255.0.0 or to 255.255.255.0.

If you can, post “netstat -ni, netstat -nr”, that will give a
clear picture of the connectivate.

  1. is “ping ..75.90” works?

  2. is “nslookup” contact the nameserver ? Is it showing you the right
    server address (..75.90)

  3. What is "ping " returned ? Is it resolved the name?

  4. The name you giveing “gethostbyname()”, is it in /etc/hosts or
    is it in nameserver? Can you "nslookup " to resolve it?

  5. you may consider change your /etc/resolv.conf as:

domain nairc.ac.cn
lookup file bind
nameserver ..75.90

This will tell resolver check /etc/hosts first, if can’t find,
check nameserver.

-xtang@qnx.com

Ivan Bannon <> ivan.bannon@rjginc.com> > wrote in message
news:8omk1t$obg$> 1@inn.qnx.com> …
Check out the file “/etc/resolv.conf” and be sure it defines your
nameserver
correctly. That may be your problem

Ivan

zhoujun <> jzhou@mail.nairc.ac.cn> > wrote in message
news:8okteh$pvd$> 1@inn.qnx.com> …
On QNX 4.25, I failed to execute function gethostbyname().
I am sure something is wrong with my system configuration,but, I can’t
find
it out and correct it.

Thank you for any info.

Zhoujun

\

Thank you !
Because ..75.90 is my temp nameserver,so I change my nameserver to
..120.20; then I try to do some test. The following is the result:

“netstat -ni” & “netstat -nr” can work well.

  1. I can ping to ..120.20.

  2. “nslookup” can contact the nameserver, and show the right IP address:
    ..120.20.

  3. For example,“ping www.qnx.com” returns the right IP address.

4)The name I give “gethostbyname()”, for example, “node1”, is in
“/etc/hosts”,but not in my nameserver. I can’t “nslookup node1” to resolve
it.

But I can get right response with “ping node1” or “telnet node1”.
In the help documents on QNX, I find the following:
The nslookup utility won’t look at /etc/hosts even if the lookup keyword
is used in /etc/resolv.conf.

  1. I add “lookup file bind” to “/etc/resolv.conf” according to your
    advice,but, “nslookup node1” still can’t find “node1”.

What’s the matter?

Xiaodan Tang <xtang@qnx.com> wrote in message
news:8onccd$4da$1@nntp.qnx.com

zhoujun <> jzhou@mail.nairc.ac.cn> > wrote:
Thank you !
In my file “/etc/resolv.conf” :
domain nairc.ac.cn
nameserver ..75.90

And, the problem about gethostbyname() still exists either the netmask
is
set to 255.255.0.0 or to 255.255.255.0.

If you can, post “netstat -ni, netstat -nr”, that will give a
clear picture of the connectivate.

  1. is “ping ..75.90” works?

  2. is “nslookup” contact the nameserver ? Is it showing you the right
    server address (..75.90)

  3. What is "ping " returned ? Is it resolved the name?

  4. The name you giveing “gethostbyname()”, is it in /etc/hosts or
    is it in nameserver? Can you "nslookup " to resolve it?

  5. you may consider change your /etc/resolv.conf as:

domain nairc.ac.cn
lookup file bind
nameserver ..75.90

This will tell resolver check /etc/hosts first, if can’t find,
check nameserver.

xtang@qnx.com

Ivan Bannon <> ivan.bannon@rjginc.com> > wrote in message
news:8omk1t$obg$> 1@inn.qnx.com> …
Check out the file “/etc/resolv.conf” and be sure it defines your
nameserver
correctly. That may be your problem

Ivan

zhoujun <> jzhou@mail.nairc.ac.cn> > wrote in message
news:8okteh$pvd$> 1@inn.qnx.com> …
On QNX 4.25, I failed to execute function gethostbyname().
I am sure something is wrong with my system configuration,but, I
can’t
find
it out and correct it.

Thank you for any info.

Zhoujun

zhoujun <jzhou@mail.nairc.ac.cn> wrote:

Thank you !
Because ..75.90 is my temp nameserver,so I change my nameserver to
..120.20; then I try to do some test. The following is the result:

“netstat -ni” & “netstat -nr” can work well.

  1. I can ping to ..120.20.

  2. “nslookup” can contact the nameserver, and show the right IP address:
    ..120.20.

  3. For example,"ping > www.qnx.com> " returns the right IP address.

4)The name I give “gethostbyname()”, for example, “node1”, is in
“/etc/hosts”,but not in my nameserver. I can’t “nslookup node1” to resolve
it.

But I can get right response with “ping node1” or “telnet node1”.
In the help documents on QNX, I find the following:
The nslookup utility won’t look at /etc/hosts even if the lookup keyword
is used in /etc/resolv.conf.

  1. I add “lookup file bind” to “/etc/resolv.conf” according to your
    advice,but, “nslookup node1” still can’t find “node1”.

But your “gethostbyname(“node1”)” is succeesed, right? (Cause you could
ping/telnet to “node1”).

nslookup using different resolver as others. It ONLY talk to a nameserver,
resolving names. Others, ping/telnet, they using the resolver in libsocket,
which understand “lookup file bind”, menas they will check /etc/hosts first,
then DNS.

-xtang@qnx.com

What’s the matter?

Xiaodan Tang <> xtang@qnx.com> > wrote in message
news:8onccd$4da$> 1@nntp.qnx.com> …
zhoujun <> jzhou@mail.nairc.ac.cn> > wrote:
Thank you !
In my file “/etc/resolv.conf” :
domain nairc.ac.cn
nameserver ..75.90

And, the problem about gethostbyname() still exists either the netmask
is
set to 255.255.0.0 or to 255.255.255.0.

If you can, post “netstat -ni, netstat -nr”, that will give a
clear picture of the connectivate.

  1. is “ping ..75.90” works?

  2. is “nslookup” contact the nameserver ? Is it showing you the right
    server address (..75.90)

  3. What is "ping " returned ? Is it resolved the name?

  4. The name you giveing “gethostbyname()”, is it in /etc/hosts or
    is it in nameserver? Can you "nslookup " to resolve it?

  5. you may consider change your /etc/resolv.conf as:

domain nairc.ac.cn
lookup file bind
nameserver ..75.90

This will tell resolver check /etc/hosts first, if can’t find,
check nameserver.

xtang@qnx.com

Ivan Bannon <> ivan.bannon@rjginc.com> > wrote in message
news:8omk1t$obg$> 1@inn.qnx.com> …
Check out the file “/etc/resolv.conf” and be sure it defines your
nameserver
correctly. That may be your problem

Ivan

zhoujun <> jzhou@mail.nairc.ac.cn> > wrote in message
news:8okteh$pvd$> 1@inn.qnx.com> …
On QNX 4.25, I failed to execute function gethostbyname().
I am sure something is wrong with my system configuration,but, I
can’t
find
it out and correct it.

Thank you for any info.

Zhoujun

It is just the question. My “gethostbyname(“node1”)” is not succeeded On
QNX 4.25, and it returns NULL. It can be rightly executed on my Redhat 6.0.
I am really muddled.

Xiaodan Tang <xtang@qnx.com> wrote in message
news:8oobav$lul$1@nntp.qnx.com

zhoujun <> jzhou@mail.nairc.ac.cn> > wrote:
Thank you !
Because ..75.90 is my temp nameserver,so I change my nameserver to
..120.20; then I try to do some test. The following is the result:

“netstat -ni” & “netstat -nr” can work well.

  1. I can ping to ..120.20.

  2. “nslookup” can contact the nameserver, and show the right IP address:
    ..120.20.

  3. For example,"ping > www.qnx.com> " returns the right IP address.

4)The name I give “gethostbyname()”, for example, “node1”, is in
“/etc/hosts”,but not in my nameserver. I can’t “nslookup node1” to
resolve
it.

But I can get right response with “ping node1” or “telnet node1”.
In the help documents on QNX, I find the following:
The nslookup utility won’t look at /etc/hosts even if the lookup
keyword
is used in /etc/resolv.conf.

  1. I add “lookup file bind” to “/etc/resolv.conf” according to your
    advice,but, “nslookup node1” still can’t find “node1”.

But your “gethostbyname(“node1”)” is succeesed, right? (Cause you could
ping/telnet to “node1”).

nslookup using different resolver as others. It ONLY talk to a
nameserver,
resolving names. Others, ping/telnet, they using the resolver in
libsocket,
which understand “lookup file bind”, menas they will check /etc/hosts
first,
then DNS.

xtang@qnx.com

What’s the matter?

Xiaodan Tang <> xtang@qnx.com> > wrote in message
news:8onccd$4da$> 1@nntp.qnx.com> …
zhoujun <> jzhou@mail.nairc.ac.cn> > wrote:
Thank you !
In my file “/etc/resolv.conf” :
domain nairc.ac.cn
nameserver ..75.90

And, the problem about gethostbyname() still exists either the
netmask
is
set to 255.255.0.0 or to 255.255.255.0.

If you can, post “netstat -ni, netstat -nr”, that will give a
clear picture of the connectivate.

  1. is “ping ..75.90” works?

  2. is “nslookup” contact the nameserver ? Is it showing you the right
    server address (..75.90)

  3. What is "ping " returned ? Is it resolved the name?

  4. The name you giveing “gethostbyname()”, is it in /etc/hosts or
    is it in nameserver? Can you "nslookup " to resolve it?

  5. you may consider change your /etc/resolv.conf as:

domain nairc.ac.cn
lookup file bind
nameserver ..75.90

This will tell resolver check /etc/hosts first, if can’t find,
check nameserver.

xtang@qnx.com

Ivan Bannon <> ivan.bannon@rjginc.com> > wrote in message
news:8omk1t$obg$> 1@inn.qnx.com> …
Check out the file “/etc/resolv.conf” and be sure it defines your
nameserver
correctly. That may be your problem

Ivan

zhoujun <> jzhou@mail.nairc.ac.cn> > wrote in message
news:8okteh$pvd$> 1@inn.qnx.com> …
On QNX 4.25, I failed to execute function gethostbyname().
I am sure something is wrong with my system configuration,but, I
can’t
find
it out and correct it.

Thank you for any info.

Zhoujun
\

zhoujun <jzhou@mail.nairc.ac.cn> wrote:

It is just the question. My “gethostbyname(“node1”)” is not succeeded On
QNX 4.25, and it returns NULL. It can be rightly executed on my Redhat 6.0.
I am really muddled.

I was confused.

Are you saying your “gethostbyname(“node1”)” is not succeeded even if
you could “ping node1” from the same QNX 4.25 machine? (ping IS
using gethostbyname() if you give it a name).

xtang@qnx.com


Xiaodan Tang <> xtang@qnx.com> > wrote in message
news:8oobav$lul$> 1@nntp.qnx.com> …
zhoujun <> jzhou@mail.nairc.ac.cn> > wrote:
Thank you !
Because ..75.90 is my temp nameserver,so I change my nameserver to
..120.20; then I try to do some test. The following is the result:

“netstat -ni” & “netstat -nr” can work well.

  1. I can ping to ..120.20.

  2. “nslookup” can contact the nameserver, and show the right IP address:
    ..120.20.

  3. For example,"ping > www.qnx.com> " returns the right IP address.

4)The name I give “gethostbyname()”, for example, “node1”, is in
“/etc/hosts”,but not in my nameserver. I can’t “nslookup node1” to
resolve
it.

But I can get right response with “ping node1” or “telnet node1”.
In the help documents on QNX, I find the following:
The nslookup utility won’t look at /etc/hosts even if the lookup
keyword
is used in /etc/resolv.conf.

  1. I add “lookup file bind” to “/etc/resolv.conf” according to your
    advice,but, “nslookup node1” still can’t find “node1”.

But your “gethostbyname(“node1”)” is succeesed, right? (Cause you could
ping/telnet to “node1”).

nslookup using different resolver as others. It ONLY talk to a
nameserver,
resolving names. Others, ping/telnet, they using the resolver in
libsocket,
which understand “lookup file bind”, menas they will check /etc/hosts
first,
then DNS.

xtang@qnx.com

What’s the matter?

Xiaodan Tang <> xtang@qnx.com> > wrote in message
news:8onccd$4da$> 1@nntp.qnx.com> …
zhoujun <> jzhou@mail.nairc.ac.cn> > wrote:
Thank you !
In my file “/etc/resolv.conf” :
domain nairc.ac.cn
nameserver ..75.90

And, the problem about gethostbyname() still exists either the
netmask
is
set to 255.255.0.0 or to 255.255.255.0.

If you can, post “netstat -ni, netstat -nr”, that will give a
clear picture of the connectivate.

  1. is “ping ..75.90” works?

  2. is “nslookup” contact the nameserver ? Is it showing you the right
    server address (..75.90)

  3. What is "ping " returned ? Is it resolved the name?

  4. The name you giveing “gethostbyname()”, is it in /etc/hosts or
    is it in nameserver? Can you "nslookup " to resolve it?

  5. you may consider change your /etc/resolv.conf as:

domain nairc.ac.cn
lookup file bind
nameserver ..75.90

This will tell resolver check /etc/hosts first, if can’t find,
check nameserver.

xtang@qnx.com

Ivan Bannon <> ivan.bannon@rjginc.com> > wrote in message
news:8omk1t$obg$> 1@inn.qnx.com> …
Check out the file “/etc/resolv.conf” and be sure it defines your
nameserver
correctly. That may be your problem

Ivan

zhoujun <> jzhou@mail.nairc.ac.cn> > wrote in message
news:8okteh$pvd$> 1@inn.qnx.com> …
On QNX 4.25, I failed to execute function gethostbyname().
I am sure something is wrong with my system configuration,but, I
can’t
find
it out and correct it.

Thank you for any info.

Zhoujun
\

Yes, my question is just that. I have tested the function for many times on
QNX 4.25, but I have never gotten the right result. It always returns
“NULL”;but on the same QNX 4.25 machine, “ping node1” or “telnet node1” can
execute successfully.

Xiaodan Tang <xtang@qnx.com> wrote in message
news:8ork56$jjc$1@nntp.qnx.com

zhoujun <> jzhou@mail.nairc.ac.cn> > wrote:
It is just the question. My “gethostbyname(“node1”)” is not succeeded
On
QNX 4.25, and it returns NULL. It can be rightly executed on my Redhat
6.0.
I am really muddled.

I was confused.

Are you saying your “gethostbyname(“node1”)” is not succeeded even if
you could “ping node1” from the same QNX 4.25 machine? (ping IS
using gethostbyname() if you give it a name).

xtang@qnx.com


Xiaodan Tang <> xtang@qnx.com> > wrote in message
news:8oobav$lul$> 1@nntp.qnx.com> …
zhoujun <> jzhou@mail.nairc.ac.cn> > wrote:
Thank you !
Because ..75.90 is my temp nameserver,so I change my nameserver to
..120.20; then I try to do some test. The following is the result:

“netstat -ni” & “netstat -nr” can work well.

  1. I can ping to ..120.20.

  2. “nslookup” can contact the nameserver, and show the right IP
    address:
    ..120.20.

  3. For example,"ping > www.qnx.com> " returns the right IP address.

4)The name I give “gethostbyname()”, for example, “node1”, is in
“/etc/hosts”,but not in my nameserver. I can’t “nslookup node1” to
resolve
it.

But I can get right response with “ping node1” or “telnet node1”.
In the help documents on QNX, I find the following:
The nslookup utility won’t look at /etc/hosts even if the lookup
keyword
is used in /etc/resolv.conf.

  1. I add “lookup file bind” to “/etc/resolv.conf” according to your
    advice,but, “nslookup node1” still can’t find “node1”.

But your “gethostbyname(“node1”)” is succeesed, right? (Cause you could
ping/telnet to “node1”).

nslookup using different resolver as others. It ONLY talk to a
nameserver,
resolving names. Others, ping/telnet, they using the resolver in
libsocket,
which understand “lookup file bind”, menas they will check /etc/hosts
first,
then DNS.

xtang@qnx.com

What’s the matter?

Xiaodan Tang <> xtang@qnx.com> > wrote in message
news:8onccd$4da$> 1@nntp.qnx.com> …
zhoujun <> jzhou@mail.nairc.ac.cn> > wrote:
Thank you !
In my file “/etc/resolv.conf” :
domain nairc.ac.cn
nameserver ..75.90

And, the problem about gethostbyname() still exists either the
netmask
is
set to 255.255.0.0 or to 255.255.255.0.

If you can, post “netstat -ni, netstat -nr”, that will give a
clear picture of the connectivate.

  1. is “ping ..75.90” works?

  2. is “nslookup” contact the nameserver ? Is it showing you the
    right
    server address (..75.90)

  3. What is "ping " returned ? Is it resolved the name?

  4. The name you giveing “gethostbyname()”, is it in /etc/hosts or
    is it in nameserver? Can you "nslookup " to resolve it?

  5. you may consider change your /etc/resolv.conf as:

domain nairc.ac.cn
lookup file bind
nameserver ..75.90

This will tell resolver check /etc/hosts first, if can’t find,
check nameserver.

xtang@qnx.com

Ivan Bannon <> ivan.bannon@rjginc.com> > wrote in message
news:8omk1t$obg$> 1@inn.qnx.com> …
Check out the file “/etc/resolv.conf” and be sure it defines your
nameserver
correctly. That may be your problem

Ivan

zhoujun <> jzhou@mail.nairc.ac.cn> > wrote in message
news:8okteh$pvd$> 1@inn.qnx.com> …
On QNX 4.25, I failed to execute function gethostbyname().
I am sure something is wrong with my system configuration,but,
I
can’t
find
it out and correct it.

Thank you for any info.

Zhoujun


\

zhoujun <jzhou@mail.nairc.ac.cn> wrote:

Yes, my question is just that. I have tested the function for many times on
QNX 4.25, but I have never gotten the right result. It always returns
“NULL”;but on the same QNX 4.25 machine, “ping node1” or “telnet node1” can
execute successfully.

That’s strange. As I said, “ping” IS using a gethostbyname() on
the node name you give it.

Can you do this:

env

ping -c1 node1

cat .c

cc -o mytest .c -lsocket

./mytest

Post the output of each command. The “your test program”.c is
the program showing how your “gethostbyname()” failed.

-xiaodan


Xiaodan Tang <> xtang@qnx.com> > wrote in message
news:8ork56$jjc$> 1@nntp.qnx.com> …
zhoujun <> jzhou@mail.nairc.ac.cn> > wrote:
It is just the question. My “gethostbyname(“node1”)” is not succeeded
On
QNX 4.25, and it returns NULL. It can be rightly executed on my Redhat
6.0.
I am really muddled.

I was confused.

Are you saying your “gethostbyname(“node1”)” is not succeeded even if
you could “ping node1” from the same QNX 4.25 machine? (ping IS
using gethostbyname() if you give it a name).

xtang@qnx.com


Xiaodan Tang <> xtang@qnx.com> > wrote in message
news:8oobav$lul$> 1@nntp.qnx.com> …
zhoujun <> jzhou@mail.nairc.ac.cn> > wrote:
Thank you !
Because ..75.90 is my temp nameserver,so I change my nameserver to
..120.20; then I try to do some test. The following is the result:

“netstat -ni” & “netstat -nr” can work well.

  1. I can ping to ..120.20.

  2. “nslookup” can contact the nameserver, and show the right IP
    address:
    ..120.20.

  3. For example,"ping > www.qnx.com> " returns the right IP address.

4)The name I give “gethostbyname()”, for example, “node1”, is in
“/etc/hosts”,but not in my nameserver. I can’t “nslookup node1” to
resolve
it.

But I can get right response with “ping node1” or “telnet node1”.
In the help documents on QNX, I find the following:
The nslookup utility won’t look at /etc/hosts even if the lookup
keyword
is used in /etc/resolv.conf.

  1. I add “lookup file bind” to “/etc/resolv.conf” according to your
    advice,but, “nslookup node1” still can’t find “node1”.

But your “gethostbyname(“node1”)” is succeesed, right? (Cause you could
ping/telnet to “node1”).

nslookup using different resolver as others. It ONLY talk to a
nameserver,
resolving names. Others, ping/telnet, they using the resolver in
libsocket,
which understand “lookup file bind”, menas they will check /etc/hosts
first,
then DNS.

xtang@qnx.com

What’s the matter?

Xiaodan Tang <> xtang@qnx.com> > wrote in message
news:8onccd$4da$> 1@nntp.qnx.com> …
zhoujun <> jzhou@mail.nairc.ac.cn> > wrote:
Thank you !
In my file “/etc/resolv.conf” :
domain nairc.ac.cn
nameserver ..75.90

And, the problem about gethostbyname() still exists either the
netmask
is
set to 255.255.0.0 or to 255.255.255.0.

If you can, post “netstat -ni, netstat -nr”, that will give a
clear picture of the connectivate.

  1. is “ping ..75.90” works?

  2. is “nslookup” contact the nameserver ? Is it showing you the
    right
    server address (..75.90)

  3. What is "ping " returned ? Is it resolved the name?

  4. The name you giveing “gethostbyname()”, is it in /etc/hosts or
    is it in nameserver? Can you "nslookup " to resolve it?

  5. you may consider change your /etc/resolv.conf as:

domain nairc.ac.cn
lookup file bind
nameserver ..75.90

This will tell resolver check /etc/hosts first, if can’t find,
check nameserver.

xtang@qnx.com

Ivan Bannon <> ivan.bannon@rjginc.com> > wrote in message
news:8omk1t$obg$> 1@inn.qnx.com> …
Check out the file “/etc/resolv.conf” and be sure it defines your
nameserver
correctly. That may be your problem

Ivan

zhoujun <> jzhou@mail.nairc.ac.cn> > wrote in message
news:8okteh$pvd$> 1@inn.qnx.com> …
On QNX 4.25, I failed to execute function gethostbyname().
I am sure something is wrong with my system configuration,but,
I
can’t
find
it out and correct it.

Thank you for any info.

Zhoujun


\

Thank you !
The following is the output of those commands according to your post.

env

_=/usr/bin/env
ABLPATH=/qnx4/photon/translations
PHOTON=//1/dev/photon
KBD=en_US_101.kbd
PATH=/bin:/etc:/usr/bin:/etc:/usr/ucb:/usr/local/bin:/qnx4/photon/bin:
/qnx4/photon/usr/bin:/qnx4/phtk/appbuilder:/usr/bin//photon
SHELL=/bin/sh
PHFONT=/dev/phfont
PHIG=1
PHTK_PATH=/qnx4/phtk
TMPDIR=/tmp
HOME=///
PHWM=pwm
CON_KBD=USA
USER_NAME=/dev/photon
TERM=qansi-m
TZ=wast-08
HZ=1000
ABLANG=en
PHOTON_PATH=/qnx4/photon
PHSTART=1
LOGNAME=root
SYSNAME=qnx4

ping -c1 node1

PING node1.nairc.ac.cn (159.226.75.96): 56 data bytes
64 bytes from 159.226.75.96: icmp_seq=0 ttl=255 time=0 ms

node1.nairc.ac.cn ping statistics —
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 0/0/0 ms

cat test.c

#include <stdio.h>
#include <netdb.h>
main()
{
if(gethostbyname(“node1”)==NULL) printf(“error\n”);

}

cc -o mytest test.c -lsocket

/usr/watcom/10.6/bin/wcc386 -zq -ms -4r -i=/usr/watcom/10.6/usr/include -i=/
usr/include t
est.c
/usr/watcom/10.6/bin/wlink op quiet form qnx flat na mytest op priv=3 op c
libp /usr/watc
om/10.6/usr/lib:/usr/lib:. f /home/empress/test.o l
/usr/watcom/10.6/usr/lib/socket3r.lib
op offset=40k op st=32k

./mytest

error

zhoujun <jzhou@mail.nairc.ac.cn> wrote:

Thank you !
The following is the output of those commands according to your post.

env

_=/usr/bin/env
ABLPATH=/qnx4/photon/translations
PHOTON=//1/dev/photon
KBD=en_US_101.kbd
PATH=/bin:/etc:/usr/bin:/etc:/usr/ucb:/usr/local/bin:/qnx4/photon/bin:
/qnx4/photon/usr/bin:/qnx4/phtk/appbuilder:/usr/bin//photon
SHELL=/bin/sh
PHFONT=/dev/phfont
PHIG=1
PHTK_PATH=/qnx4/phtk
TMPDIR=/tmp
HOME=///
PHWM=pwm
CON_KBD=USA
USER_NAME=/dev/photon
TERM=qansi-m
TZ=wast-08
HZ=1000
ABLANG=en
PHOTON_PATH=/qnx4/photon
PHSTART=1
LOGNAME=root
SYSNAME=qnx4

ping -c1 node1

PING node1.nairc.ac.cn (159.226.75.96): 56 data bytes
64 bytes from 159.226.75.96: icmp_seq=0 ttl=255 time=0 ms

node1.nairc.ac.cn ping statistics —
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 0/0/0 ms

cat test.c

#include <stdio.h
#include <netdb.h
main()
{
if(gethostbyname(“node1”)==NULL) printf(“error\n”);

}

cc -o mytest test.c -lsocket

/usr/watcom/10.6/bin/wcc386 -zq -ms -4r -i=/usr/watcom/10.6/usr/include -i=/
usr/include t
est.c
/usr/watcom/10.6/bin/wlink op quiet form qnx flat na mytest op priv=3 op c
libp /usr/watc
om/10.6/usr/lib:/usr/lib:. f /home/empress/test.o l
/usr/watcom/10.6/usr/lib/socket3r.lib
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I’m afraid this is the problem.

Check your “/usr/lib/socket3r.lib”, it is supposed to link to
“/usr/tcptk/current/usr/lib/socket3r.lib”. You can try to
compile your program like:

cc -o mytest test.c -L/usr/tcptk/current/usr/lib -lsocket

I bet this time it will work.

The “socket3r.lib” library is belong to TCPTK package. But in
old QNX (qnx 4.24?) system, an old “socket3r.lib” in watcom c dev
package will overwrite the link.

-xtang@qnx.com

op offset=40k op st=32k

./mytest

error

Thank you !
Now, I have moved the file “/usr/watcom/10.6/usr/lib/socket3r.lib” to file
“/usr/watcom/10.6/usr/lib/socket3r.bk.lib” . After I compile file “test.c”
with “cc -o mytest test.c -lsocket”, “./mytest” can return right result.

But, when I install a database software written by Empress Software Inc.,the
error “*** System Error *** gethostbyname() failed” still appears.

By the way,“node1” is my hostname.


Xiaodan Tang <xtang@qnx.com> wrote in message
news:8otq8h$ri5$1@nntp.qnx.com

zhoujun <> jzhou@mail.nairc.ac.cn> > wrote:
Thank you !
The following is the output of those commands according to your post.

env

_=/usr/bin/env
ABLPATH=/qnx4/photon/translations
PHOTON=//1/dev/photon
KBD=en_US_101.kbd
PATH=/bin:/etc:/usr/bin:/etc:/usr/ucb:/usr/local/bin:/qnx4/photon/bin:
/qnx4/photon/usr/bin:/qnx4/phtk/appbuilder:/usr/bin//photon
SHELL=/bin/sh
PHFONT=/dev/phfont
PHIG=1
PHTK_PATH=/qnx4/phtk
TMPDIR=/tmp
HOME=///
PHWM=pwm
CON_KBD=USA
USER_NAME=/dev/photon
TERM=qansi-m
TZ=wast-08
HZ=1000
ABLANG=en
PHOTON_PATH=/qnx4/photon
PHSTART=1
LOGNAME=root
SYSNAME=qnx4

ping -c1 node1

PING node1.nairc.ac.cn (159.226.75.96): 56 data bytes
64 bytes from 159.226.75.96: icmp_seq=0 ttl=255 time=0 ms

node1.nairc.ac.cn ping statistics —
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 0/0/0 ms

cat test.c

#include <stdio.h
#include <netdb.h
main()
{
if(gethostbyname(“node1”)==NULL) printf(“error\n”);

}

cc -o mytest test.c -lsocket

/usr/watcom/10.6/bin/wcc386 -zq -ms -4r -i=/usr/watcom/10.6/usr/include -i=/
usr/include t
est.c
/usr/watcom/10.6/bin/wlink op quiet form qnx flat na mytest op priv=3 op
c
libp /usr/watc
om/10.6/usr/lib:/usr/lib:. f /home/empress/test.o l
/usr/watcom/10.6/usr/lib/socket3r.lib
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I’m afraid this is the problem.

Check your “/usr/lib/socket3r.lib”, it is supposed to link to
“/usr/tcptk/current/usr/lib/socket3r.lib”. You can try to
compile your program like:

cc -o mytest test.c -L/usr/tcptk/current/usr/lib -lsocket

I bet this time it will work.

The “socket3r.lib” library is belong to TCPTK package. But in
old QNX (qnx 4.24?) system, an old “socket3r.lib” in watcom c dev
package will overwrite the link.

xtang@qnx.com

op offset=40k op st=32k

./mytest

error

zhoujun <jzhou@mail.nairc.ac.cn> wrote:

Thank you !
Now, I have moved the file “/usr/watcom/10.6/usr/lib/socket3r.lib” to file
“/usr/watcom/10.6/usr/lib/socket3r.bk.lib” . After I compile file “test.c”
with “cc -o mytest test.c -lsocket”, “./mytest” can return right result.

But, when I install a database software written by Empress Software Inc.,the
error “*** System Error *** gethostbyname() failed” still appears.

By the way,“node1” is my hostname.

So this database software is static linking with old library.
With old gethostbyname(), you only have 2 choice:

  1. add “node1” into your name server, so while gethostbyname() checked
    nameserver, it will got a successful reply.

or

  1. remove /etc/resolv.conf file. Thus gethostbyname() will only check
    /etc/hosts and resolve “node1”.

-xtang@qnx.com


Xiaodan Tang <> xtang@qnx.com> > wrote in message
news:8otq8h$ri5$> 1@nntp.qnx.com> …
zhoujun <> jzhou@mail.nairc.ac.cn> > wrote:
Thank you !
The following is the output of those commands according to your post.

env

_=/usr/bin/env
ABLPATH=/qnx4/photon/translations
PHOTON=//1/dev/photon
KBD=en_US_101.kbd
PATH=/bin:/etc:/usr/bin:/etc:/usr/ucb:/usr/local/bin:/qnx4/photon/bin:
/qnx4/photon/usr/bin:/qnx4/phtk/appbuilder:/usr/bin//photon
SHELL=/bin/sh
PHFONT=/dev/phfont
PHIG=1
PHTK_PATH=/qnx4/phtk
TMPDIR=/tmp
HOME=///
PHWM=pwm
CON_KBD=USA
USER_NAME=/dev/photon
TERM=qansi-m
TZ=wast-08
HZ=1000
ABLANG=en
PHOTON_PATH=/qnx4/photon
PHSTART=1
LOGNAME=root
SYSNAME=qnx4

ping -c1 node1

PING node1.nairc.ac.cn (159.226.75.96): 56 data bytes
64 bytes from 159.226.75.96: icmp_seq=0 ttl=255 time=0 ms

node1.nairc.ac.cn ping statistics —
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 0/0/0 ms

cat test.c

#include <stdio.h
#include <netdb.h
main()
{
if(gethostbyname(“node1”)==NULL) printf(“error\n”);

}

cc -o mytest test.c -lsocket

/usr/watcom/10.6/bin/wcc386 -zq -ms -4r -i=/usr/watcom/10.6/usr/include -i=/
usr/include t
est.c
/usr/watcom/10.6/bin/wlink op quiet form qnx flat na mytest op priv=3 op
c
libp /usr/watc
om/10.6/usr/lib:/usr/lib:. f /home/empress/test.o l
/usr/watcom/10.6/usr/lib/socket3r.lib
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I’m afraid this is the problem.

Check your “/usr/lib/socket3r.lib”, it is supposed to link to
“/usr/tcptk/current/usr/lib/socket3r.lib”. You can try to
compile your program like:

cc -o mytest test.c -L/usr/tcptk/current/usr/lib -lsocket

I bet this time it will work.

The “socket3r.lib” library is belong to TCPTK package. But in
old QNX (qnx 4.24?) system, an old “socket3r.lib” in watcom c dev
package will overwrite the link.

xtang@qnx.com

op offset=40k op st=32k

./mytest

error