Page 1 of 1

Gethostbyname...

Posted: Mon Nov 09, 2015 2:42 pm
by Skipsy
Hi all,

Iam using GetHostByname_() to resolve dns PC name to xxx.xxx.xxx.xxx format IP.
Works fine but I have read Micro$oft notice saying that this function is deprecated (!)
They suggest to use GetAddrInfo()... Why not, but this function is unknown by the compiler (v4.51)

Any suggestion :?: :?:

Thanks,
WW

Re: Gethostbyname...

Posted: Mon Nov 09, 2015 3:31 pm
by RSBasic
You have to import this WinAPI function.
Example: http://www.purebasic.fr/english/viewtop ... 12&t=52402

Code: Select all

Prototype Pgetaddrinfo(pNodeName, pServiceName, pHints, ppResult)
Global getaddrinfo.Pgetaddrinfo

Lib_Winsock = OpenLibrary(#PB_Any,"ws2_32.dll")
If IsLibrary(Lib_Winsock)<> 0
  getaddrinfo.Pgetaddrinfo=GetFunction(Lib_Winsock,"GetAddrInfoW")
EndIf
(Code by SFSxOI, not tested)

Re: Gethostbyname...

Posted: Mon Nov 09, 2015 5:47 pm
by ts-soft
@RSBasic
Better use pseudotype:

Code: Select all

Prototype Pgetaddrinfo(NodeName.p-Unicode, ServiceName.p-Unicode, *Hints, *Result)

Re: Gethostbyname...

Posted: Mon Nov 09, 2015 5:57 pm
by Skipsy
GREAT !!
(I just have to understand now).

Thank you.
WW