Resolve the string host, and fill in the IPaddress pointed to by address with the resolved IP and the port number passed in through port.
[Visual Basic]
Public Shared Function SDLNet_ResolveHost( _
ByRef
address As
IPaddress, _
ByVal
host As
String, _
ByVal
port As
Short _
) As
Integer
Parameters
-
address
- This points to the IPaddress that will be filled in. It doesn't need to be set before calling this, but it must be allocated in memory.
-
host
- For connecting to a server, this is the hostname or IP in a string. For becoming a server, this is NULL. If you do use NULL, all network interfaces would be listened to for incoming connections, using the INADDR_ANY address.
-
port
- For connecting to a server, this is the the servers listening port number. For becoming a server, this is the port to listen on. If you are just doing Domain Name Resolution functions, this can be 0.
Return Value
0 on success. -1 on errors, plus address.host will be INADDR_NONE. An error would likely be that the address could not be resolved. If 'host' is NULL, the resolved host will be set to INADDR_ANY.
Remarks
This is the best way to fill in the IPaddress struct for later use. This function does not actually open any sockets, it is used to prepare the arguments for the socket opening functions. WARNING: this function will put the host and port into Network Byte Order into the address fields, so make sure you pass in the data in your hosts byte order. (normally not an issue)
Binds to C-function call in SDL_net.h:
extern DECLSPEC int SDLCALL SDLNet_ResolveHost(IPaddress *address, const char *host, Uint16 port)
Example
For a server listening on all interfaces, on port 1234:
// create a server type IPaddress on port 1234
IPaddress ipaddress;
SDLNet_ResolveHost(ipaddress, NULL, 1234);
For a client connecting to "host.domain.ext", at port 1234:
// create an IPaddress for host name "host.domain.ext" on port 1234
// this is used by a client
IPaddress ipaddress;
SDLNet_ResolveHost(ipaddress, "host.domain.ext", 1234);
See Also
SdlNet Class | Tao.Sdl Namespace | SDLNet_ResolveIP | SdlNet.IPaddress