WSHGetSockaddrType
INT
WSHGetSockaddrType(
IN PSOCKADDR Sockaddr,
IN DWORD SockaddrLength,
OUT PSOCKADDR_INFO SockaddrInfo
);
WSHGetSockaddrType parses a socket address and returns information
about it to Windows Sockets.
Parameters
-
Sockaddr
-
Points to the SOCKADDR structure to be evaluated.
-
SockaddrLength
-
Specifies the length, in bytes, of the SOCKADDR structure at Sockaddr.
-
SockaddrInfo
-
Points to a buffer in which the helper DLL returns information about the
socket address, formatted as a SOCKADDR_INFO structure.
Return Value
WSHGetSockaddrType returns zero if the given socket address is valid
for the address family supported by this helper DLL. Otherwise, it returns a
Windows Sockets error code.
Comments
Windows Sockets calls WSHGetSockaddrType when it needs information
about a SOCKADDR. The helper DLL evaluates both the machine address and
endpoint portions of the SOCKADDR. The machine-address portion specifies a
particular machine, for example, the IP address in an internet address. The
endpoint specifies a particular service on a machine, corresponding to the
port number in an internet address.
The SOCKADDR_INFO structure is defined as follows:
typedef struct _SOCKADDR_INFO {
SOCKADDR_ADDRESS_INFO AddressInfo;
SOCKADDR_ENDPOINT_INFO EndpointInfo;
} SOCKADDR_INFO, *PSOCKADDR_INFO;
SOCKADDR_ADDRESS_INFO is an enumerated type, with the following
possible values:
-
SockaddrAddressInfoNormal
-
The address portion of the SOCKADDR has no unusual characteristics.
-
SockaddrAddressInfoWildcard
-
The address portion of the SOCKADDR is a “wildcard,” meaning that it does not
specify a particular address. For example, this corresponds to INADDR_ANY (0.0.0.0)
for IP addresses, which an application passes to bind when it has no
particular requirements for the IP address used for a socket.
-
SockaddrAddressInfoBroadcast
-
The address portion of the SOCKADDR refers to the address family’s broadcast
address. For example, in IP addresses, this is INADDR_BROADCAST
(255.255.255.255).
-
SockaddrAddressInfoLoopback
-
The address portion of the SOCKADDR refers to the address family’s loopback
address. For example, in internet addresses, this is INADDR_LOOPBACK
(127.0.0.1).
SOCKADDR_ENDPOINT_INFO also is an enumerated type, with the following possible
values:
-
SockaddrEndpointInfoNormal
-
The endpoint portion of the SOCKADDR has no unusual characteristics.
-
SockaddrEndpointInfoWildcard
-
The endpoint portion of the SOCKADDR is a wildcard, meaning that it could
refer to any endpoint. An application, typically a client, can pass a wildcard
endpoint to bind when it has no particular requirements for the
endpoint assigned. For example, in IP addresses, a port set to zero is a
wildcard endpoint.
-
SockaddrEndpointInfoReserved
-
The endpoint of the SOCKADDR is reserved, meaning that special privilege is
required to bind to it. For example, in internet addresses, a port with a
value less than IPPORT_RESERVED (1024) is a reserved endpoint.