|
Home > Archive > Unix Programming > October 2006 > where does gethostname() get the host name
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
where does gethostname() get the host name
|
|
| freegnu 2006-10-27, 7:19 am |
| hi all, when i run program on the target host, i find the gethostname(hostname) get none, i dont know gethostname(hostname) how to work, and which files depend on?
BTW:i find there resolv.conf and hosts
| |
| Jens Thoms Toerring 2006-10-27, 7:19 am |
| freegnu <freegnu@163.com> wrote:
> hi all, when i run program on the target host, i find the
> gethostname(hostname) get none, i dont know gethostname(hostname) how to
> work, and which files depend on?
There's really not enough information to go by here. What do you mean
be "get none" - do you get -1 as the return value of the call? How do
you exactly call gethostname()? It expects two arguments, not one, do
you pass it a valid pointer to as much memory as you tell it via the
second argument and is the length large enough to hold the hostname?
What's the value of errno after the call failed?
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
|
|
|
|
|