Gethostbyname...

Just starting out? Need help? Post your questions and find answers here.
Skipsy
User
User
Posts: 98
Joined: Wed Apr 30, 2003 12:26 pm
Location: France

Gethostbyname...

Post 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
Beware of the man who has the solution before he understands the problem...
User avatar
RSBasic
Moderator
Moderator
Posts: 1228
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: Gethostbyname...

Post 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)
Image
Image
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Gethostbyname...

Post by ts-soft »

@RSBasic
Better use pseudotype:

Code: Select all

Prototype Pgetaddrinfo(NodeName.p-Unicode, ServiceName.p-Unicode, *Hints, *Result)
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Skipsy
User
User
Posts: 98
Joined: Wed Apr 30, 2003 12:26 pm
Location: France

Re: Gethostbyname...

Post by Skipsy »

GREAT !!
(I just have to understand now).

Thank you.
WW
Beware of the man who has the solution before he understands the problem...
Post Reply