Description
Get service information corresponding to a service name and protocol.
#include <winsock.h>
struct servent FAR * PASCAL FAR getservbyname ( const char FAR * name, const char FAR * proto);
name
Remarks
getservbyname() returns a pointer to the following structure which contains the name(s) and service number which correspond to the given service name.
struct servent { char FAR * s_name; char FAR * FAR *s_aliases; short s_port; char FAR * s_proto; };
The members of this structure are:
s_name
The pointer which is returned points to a structure which is allocated by the Windows Sockets library. The application must never attempt to modify this structure or to free any of its components. Furthermore only one copy of this structure is allocated per thread, and so the application should copy any information which it needs before issuing any other Windows Sockets API calls.
Return Value
If no error occurs, getservbyname() returns a pointer to the servent structure described above. Otherwise it returns a NULL pointer and a specific error number may be retrieved by calling WSAGetLastError()
Error Codes
WSANOTINITIALISED
See Also
WSAAsyncGetServByName(), getservbyport()