gethostname() patch

Pierre A. Humblet
Sat Jan 11 00:29:00 GMT 2003

At 01:02 PM 1/10/2003 +0100, Corinna Vinschen wrote:
>I've just removed some old cruft from cygwin_gethostname which had
>the annoying result that always the return value of GetComputerName()
>has been used instead of the return value of gethostname().  Now
>Cygwin's gethostname and hostname(1) report the winsock value of the
>hostname which is lower case.

Here are some experiments, with the old dll. There gethostname calls
GetComputerName if wsock32 isn't loaded, else the wsock gethostname.
With Corinna's change, the wsock gethostname is always called (at least
it's consistent). The third line below is after loading wsock, i.e. the
new value.

GetComputerName WORLDNET
gethostname WORLDNET
gethostname worldnet
 Great, that's the desired goal.

GetComputerName PHumblet
gethostname PHumblet
gethostname PHumblet
 No difference, no lower case...

GetComputerName HPN5170X
gethostname HPN5170X
gethostname Marie-Claire
 Isn't that weird? That's my spouse first name, so somebody must 
have put it there, but I don't find it in any user interface. 
Using regedit I find it in

Here are a few more experiments, first from the box itself
~: ping HPN5170X
Pinging HPN5170X [] with 32 bytes of data:
~: ping Marie-Claire
Pinging Marie-Claire [] with 32 bytes of data:
~: ping -a
Pinging HPN5170X [] with 32 bytes of data:

And from the Win98 gateway on my home network
~: ping Marie-Claire
Unknown host Marie-Claire.
~: ping HPN5170x    
Pinging HPN5170x [] with 32 bytes of data:

so ComputerName is more significant than HostName ....

>My questions is:  Shouldn't uname call this function as well?  Uname
>still uses the upper case value returned from GetComputerName().

Please don't, at least until this is explained.
To the contrary, should gethostname always call GetComputerName ???

Also, calling wsock32 gethostbyname does NOT imply lowercase.
if that's important Cygwin should change the case.

As somebody wrote on the list, those values come from different
registry entries. Why should one be the lowercase of the other?


More information about the Cygwin-developers mailing list