[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gethostname on Windows

From: Bruno Haible
Subject: Re: gethostname on Windows
Date: Thu, 2 Apr 2009 02:43:47 +0200
User-agent: KMail/1.9.9

Simon Josefsson wrote:
> The current gethostname module will return an empty string on mingw:
>   strcpy (name, "");          /* Hardcode your system name if you want.  */
> This is sub-optimal since Windows has a gethostname function in
> -lws2_32.
> The following patch should make gethostname return proper values.
> Tested on x86 debian lenny and mingw cross-compile.  Any objections to
> installing it?

Well, I don't much like the dependency on an external library for the
modules 'gethostname' and 'uname' (later, when we get an 'uname' module).

I did some experiments with the GetComputerNameEx function [1], which is
present in kernel32.dll. The parameters ComputerNameDnsHostname and
ComputerNamePhysicalDnsHostname returned the same value as gethostname()
for me, except that gethostname() returns a lowercased result (which can
be simulated in 3 lines of code).

OTOH, the gethostname() in -lws2_32 is a "Unixy" API, and it seems idiotic
want to use a "Windozy" API instead.

I'm undecided.


[1] http://msdn.microsoft.com/en-us/library/ms724301(VS.85).aspx

reply via email to

[Prev in Thread] Current Thread [Next in Thread]