Expand Minimize

getprotobyname function

The getprotobyname function retrieves the protocol information corresponding to a protocol name.

Syntax


struct PROTOENT* FAR getprotobyname(
  _In_  const char *name
);

Parameters

name [in]

Pointer to a null-terminated protocol name.

Return value

If no error occurs, getprotobyname returns a pointer to the protoent. Otherwise, it returns a null pointer and a specific error number can be retrieved by calling WSAGetLastError.

Error codeMeaning
WSANOTINITIALISED

A successful WSAStartup call must occur before using this function.

WSAENETDOWN

The network subsystem has failed.

WSAHOST_NOT_FOUND

Authoritative answer protocol not found.

WSATRY_AGAIN

A nonauthoritative protocol not found, or server failure.

WSANO_RECOVERY

Nonrecoverable errors, the protocols database is not accessible.

WSANO_DATA

Valid name, no data record of requested type.

WSAEINPROGRESS

A blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function.

WSAEFAULT

The name parameter is not a valid part of the user address space.

WSAEINTR

A blocking Windows Socket 1.1 call was canceled through WSACancelBlockingCall.

 

Remarks

The getprotobyname function returns a pointer to the protoent structure containing the name(s) and protocol number that correspond to the protocol specified in the name parameter. All strings are null-terminated. The protoent structure is allocated by the Windows Sockets library. An application must never attempt to modify this structure or to free any of its components. Furthermore, like hostent, only one copy of this structure is allocated per thread, so the application should copy any information that it needs before issuing any other Windows Sockets function calls.

Windows Phone 8: This API is supported.

Requirements

Minimum supported client

Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]

Minimum supported phone

Windows Phone 8

Header

Winsock2.h

Library

Ws2_32.lib

DLL

Ws2_32.dll

See also

Winsock Reference
Winsock Functions
getprotobynumber
WSAAsyncGetProtoByName

 

 

Community Additions

ADD
Show:
© 2014 Microsoft