getprotobyname函数

来源:互联网 发布:男生香水 知乎 编辑:程序博客网 时间:2024/05/06 06:52

getprotobyname

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

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

Parameters

name
[in] Pointer to a null-terminated protocol name.

Return Values

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 codeMeaningWSANOTINITIALISEDA successful WSAStartup call must occur before using this function.WSAENETDOWNThe network subsystem has failed.WSAHOST_NOT_FOUNDAuthoritative answer protocol not found.WSATRY_AGAINA nonauthoritative protocol not found, or server failure.WSANO_RECOVERYNonrecoverable errors, the protocols database is not accessible.WSANO_DATAValid name, no data record of requested type.WSAEINPROGRESSA blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function.WSAEFAULTThe name parameter is not a valid part of the user address space.WSAEINTRA 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.

Requirements

ClientRequires Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, Windows 98, or Windows 95.ServerRequires Windows Server 2003, Windows 2000 Server, or Windows NT Server.Header

Declared in Winsock2.h.

Library

Link to Ws2_32.lib.

DLLRequires Ws2_32.dll.

See Also

Winsock Reference, Winsock Functions, getprotobynumber, WSAAsyncGetProtoByName

原创粉丝点击