QNX RTOS v4 Knowledge Base
QNX RTOS v4 Knowledge Base
Title |
gethostname() resolving problem |
Ref. No. |
QNX.000010475 |
Category(ies) |
Network, Development, Configuration |
Issue |
When using gethostname() from tcp toolkit 424 tried to open the /etc/uucpname file and if the file did not exists, returns with an error.
If the /etc/uucpname contains the IP, or a name corresponding to the Socket name (and to the content of /etc/hosts file), it works.
However, ftp client from the same runtime (4.24) does not need any /etc/uucpname file. Whats going on?
|
Solution |
The function call gethostname() searchs the hostname in this order:
1) getenv("HOSTNAME"), if it is set, return this value.
2) Locate the socket manager, and send a _SOCK_GETHOSTNAME request to it, and return the value from socket manager. (so SOCK=1 hostname get you the hostname from node 1)
Please note, if there is no SOCK=<nid> set in the environment, the library will go to network do a global search, and grab whatever it can find.
3) if can't find the socket manager, then the function try to open /etc/uucpname.<nid>, and then /etc/uucpname, and return the string in it.
|
|