New network function

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User_Russian
Addict
Addict
Posts: 1520
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

New network function

Post by User_Russian »

In PB lacks some network functions.
Such as:

Code: Select all

IPAddressType(IP.s) ; Type IP (IPv4 or IPv6).
IPToBin(IP.s)       ; Convert IP-string (IPv4 or IPv6) in binary form (IPv4 - 4 bytes; IPv6 - 16 bytes).
IPToHostName(IP.s, Type) ; Convert IP-string (IPv4 or IPv6) in the domain name (for example 127.0.0.1 converted to localhost).
HostNameToIP(IP.s, Type) ; Convert a domain name in IP-string (IPv4 or IPv6) (for example localhost converted to 127.0.0.1).
Function IPAddressType() should determine the type of IP addresses, returning one of the following values.

Code: Select all

#PB_Network_IPv4
#PB_Network_IPv6
#PB_Error ; The address contains illegal characters or the address is incorrect.
Function IPToBin() should return the IP address in binary form. For IPv4, this is a variable of type Long, and for IPv6, it is a pointer to a structure containing the 16 byte static array (similar functions GetClientIP() and NextIPAddress()).

Function IPToHostName() must convert IP address into a domain name. Argument Type, specifies the type of IP address (IPv4 or IPv6).

Function HostNameToIP() must convert the domain name into an IP address. Argument Type, specifies the type of IP address (IPv4 or IPv6).

And it would be great if the added support for non-blocking sockets. http://www.purebasic.fr/english/viewtop ... 24#p402824