Gethostbyaddr ()

Source: Internet
Author: User
Brief description of gethostbyaddr:

Returns the host information corresponding to the given address.

# Include <Winsock. h>

Struct hostent far * Pascal far gethostbyaddr (const char

Far * ADDR, int Len, int type );

ADDR: pointer to the byte sequential address of the network.

Len: the length of the address. The value is 4 in the pf_inet type.

Type: Address type, which must be pf_inet.

Note:

Gethostbyaddr () returns the hostent structure pointer corresponding to the given address that contains the Host Name and address information. The structure declaration is as follows:

Struct hostent {

Char far * h_name;

Char far * h_aliases;

Short h_addrtype;

Short h_length;

Char far * h_addr_list;

};

Structure members include:

Member Purpose

H_name: Specifies the Host Name (PC ).

H_aliases: an optional host name queue ending with a null pointer.

H_addrtype: Type of the returned address. For Windows Sockets, this field is always pf_inet.

H_legnth the length (number of bytes) of each address, which corresponds to 4 in the pf_inet domain.

H_addr_list should be a list of host addresses ending with a null pointer, and the returned addresses are in network order

To ensure the compatibility of other old software, h_addr_list [0] is defined as macro h_addr.

The returned Pointer Points to a structure allocated by Windows Sockets. The application should not try to modify this structure or release any part of it. In addition, each thread only has a copy of this structure, so the application should copy the information it needs before calling other Windows scokets APIs.

Return Value:

If no error occurs, gethostbyaddr () returns a pointer to the hostent structure described above. Otherwise, a null pointer is returned. The application can get a specific error code through wsagetlasterror.

Error code:

Wsanotintialised must successfully call wsastartup () before applying this API ().

Wsaentdown Windows Sockets implementation detected network subsystem errors.

Wsahost_not_found does not find the authorization response host.

Wsatry_again does not find an unauthorized host or serverfail.

Errors that cannot be recovered by wsano_retimp, such as formerr, refused, and noibd.

Wsano_data is a valid name, but there is no data record about the request type.

Wsaeinprogress a blocked Windows Sockets operation is in progress.

Wsacancelblockingcall () canceled the blocked wsaeintr call.
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.