UNIX Network Programming Volume 1, Third Edition [Electronic resources] : The Sockets Networking API نسخه متنی

This is a Digital Library

With over 100,000 free electronic resource in Persian, Arabic and English

UNIX Network Programming Volume 1, Third Edition [Electronic resources] : The Sockets Networking API - نسخه متنی

Addison Wesley

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید










11.4 gethostbyaddr Function


The function gethostbyaddr takes a binary IPv4 address and tries to find the hostname corresponding to that address. This is the reverse of gethostbyname.

#include <netdb.h>

struct hostent *gethostbyaddr (const char *

addr , socklen_t

len , int

family );

Returns: non-null pointer if OK, NULL on error with h_errno set

This function returns a pointer to the same hostent structure that we described with gethostbyname. The field of interest in this structure is normally h_name, the canonical hostname.

The

addr argument is not a char*, but is really a pointer to an in_addr structure containing the IPv4 address.

len is the size of this structure: 4 for an IPv4 address. The

family argument is AF_INET.

In terms of the DNS, gethostbyaddr queries a name server for a PTR record in the in-addr.arpa domain.


/ 450