A question about gethostbyname()

Thank you !
According to your 2nd advice, I failed.
Now, we are contacting with Empress Software Inc… Maybe we can skip that
problem.

Xiaodan Tang <xtang@ottawa.com> wrote in message
news:8ova0u$mfo$1@nntp.qnx.com

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


\