Platform SDK: Windows Sockets

getservbyname and getservbyport Functions in the SPI

The WSALookupServiceBegin query uses SVCID_INET_SERVICEBYNAME as the service class GUID. The lpszServiceInstanceName parameter references a string which indicates the service name or service port, and (optionally) the service protocol. The formatting of the string is illustrated as ftp/tcp or 21/tcp or just ftp. The string is not case sensitive. The slash mark, if present, separates the protocol identifier from the preceding part of the string. The Ws2_32.dll will specify LUP_RETURN_BLOB and the NSP will place a SERVENT structure in the blob (using offsets instead of pointers as described above). NSPs should honor these other LUP_RETURN_* flags as well.

Flag Description
LUP_RETURN_NAME Returns the s_name member from SERVENT structure in lpszServiceInstanceName.
LUP_RETURN_TYPE Returns canonical GUID in lpServiceClassId It is understood that a service identified as ftp or 21 may be on another port according to locally established conventions. The s_port member of the SERVENT structure should indicate where the service can be contacted in the local environment. The canonical GUID returned when LUP_RETURN_TYPE is set should be one of the predefined GUIDs from svcs.h that corresponds to the port number indicated in the SERVENT structure.