[Gambas-devel] Gambas DNS resolution working in Windows, patch, new screenshot

Brandon Bergren bdragon at ...185...
Wed Feb 16 00:39:36 CET 2005


On Wed, 16 Feb 2005, Daniel Campos wrote:

>
>> 
>> Daniel: Why are you using reentrant functions inside a semaphore? Isn't it 
>> safe to use the non-reentrant ones there?
>
>
> No, I tried that, but I was unable to use gethostbyname() because once the 
> object try to kill the thread (for example if the user cancels the 
> operation), the dns query never works again until the program is closed and 
> restarted. that is the reason of the gethostbyname_r existence.
>
>> I can't use gethostbyname_r or gethostbyaddr_r on Cygwin. They don't exist 
>> and are nonportable. I didn't have any crashes with this patch, but it's a 
>> lazy hack.  Do you have a better idea how to handle this?
>> 
>> (BTW, there's a PD implementation of gethostbyname_r at
>> http://www.cygwin.com/ml/cygwin/2004-04/msg00532.html
>> )
>
> Mmmhh... well I don't know very much about Cygwin... may be it is possible to 
> use the Win$ native functions to
> implement it? I think these functions are asynchronous ( I had to use them, a 
> lot of time ago, for a
> Windows program)
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/wsaasyncgethostbyname_2.asp
>

Yeah, winsock... Blech... Maybe when I get to the point a native port is 
feasable.

>> 
>> Shouldn't we be using getaddrinfo and getnameinfo instead? Or are those too 
>> new to be implemented everywhere?
>
>
> Well, gethostbyname_r works OK for Linux systems, so I won't change that 
> implementation, however if Cygwin
> can use getaddrinfo and getnameinfo, I can try to write a #ifdef CYGWIN... 
> patch
>
> Regards,
>
> D. Campos
>
Of course, Linux is notoriously nonstandard. Also, even linux has 
deprecated this function.

http://www.linuxbase.org/spec/book/LSB-generic/LSB-generic/baselib-gethostbyname-r-3.html

I mean in general.  gethostbyname and 
gethostbyaddr are obselete, and the reentrant versions weren't defined by 
POSIX. (Plus there's the whole debate on what the proper arguments are.) I 
just think getaddrinfo and getnameinfo would be cleaner and less error-prone.

Really, getaddrinfo and getnameinfo should be preferred if available. 
They are cleaner and well defined by POSIX.

http://www.ietf.org/rfc/rfc2553.txt

But, you're the maintainer, so it's definately your call...

I still say gethostby* should be the FALLBACK functions, not the PREFERRED 
functions, though.

Grain of salt, though, as I've never written a real-world network program 
in C.

--Brandon Bergren




More information about the Devel mailing list