bug-gnulib
[Top][All Lists]
Advanced

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

Re: (x)gethostname


From: Simon Josefsson
Subject: Re: (x)gethostname
Date: Fri, 18 Jan 2008 12:11:44 +0100
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.1 (gnu/linux)

Bruno Haible <address@hidden> writes:

> Hi Simon,
>
>> > But this is still not complete: The doc/functions/gethostname.texi file
>> > says that the problem is that mingw lacks a gethostname function.
>> 
>> This is not the case now, and I'm not sure it ever was.  Where did that
>> information come from?
>
> I wrote it: I saw that the .m4 macro only looked whether the function was
> missing and, based on the results of "nm" on various systems' libraries,
> found that mingw was such a system. Evidently I didn't consider ws2_32 as
> a system library.

It would be useful to collect nm from ws_32 (and winsock32) as well, for
reference.  As for it being a system library, I'm not sure.  It appears
to contain functions that POSIX considers to be system functions.

If you know how to collect this data for Windows 95, 98 etc, it may be
useful to understand which functions are available in which releases.

>> For reference, the Windows documentation for gethostname is:
>> 
>> http://msdn2.microsoft.com/en-us/library/ms738527.aspx
>
> Thanks for the reference. So, to accomodate this function, we need a
> rpl_gethostname that calls gethostname and accomodates
>   1. for the need to call WSAStartup() before,
>      This will require a new module 'sockets' in gnulib, because obviously
>      we don't want to call WSAStartup() more than once.
>   2. for the conversion from a WSA* error code to an <errno.h> error code.
>      This will require, in particular, an 'errno' module and a modification
>      to the 'strerror' module.

I think you are right.

>> The MSDN documentation says it is in winsock2.h and ws2_32, so I think
>> we should use those headers/libraries until we know a reason to prefer
>> winsock.h and wsock32.
>
> Yes, I agree. Your sys_socket module already uses winsock2; there is no
> point in mixing two different implementations of socket libraries.

Actually, I think mixing them will break, but I'm not sure.  Let's hope
we never need to consider winsock2.h or wsock32.dll.  My understanding
is that they are only needed for old Windows releases (e.g., Windows
3.x, Windows 95 or Windows 98) without service packs, since they don't
have the newer winsock libraries.

>> > And it is necessary to still override the function, in order to
>> > WSAStartup before?
>> 
>> No, this doesn't seem to be necessary, at least under Wine.
>
> I don't think that you can judge the behaviour of Windows by testing on
> Wine. You know that Wine reimplements every DLL, so in particular Wine's
> winsock is a different implementation that Windows winsock.

Let's trust the documentation.  What surprised me was that I recall
seeing failures under Wine because WSAStartup() wasn't called, so I
guessed that possibly Wine follows Windows behaviour.

/Simon




reply via email to

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