IceWalkers.com - Linux Software downloads and news
Name : Password :
Linux SoftwareLinux RPMLinux HowtosLink UsAboutAdvertise

getnameinfo (3)

getnameinfo(3)             UNIX Programmer's Manual             getnameinfo(3)



NAME
       getnameinfo  - address-to-name translation in protocol-independent man-
       ner

SYNOPSIS
       #include<sys/socket.h>
       #include<netdb.h>

       intgetnameinfo(conststructsockaddr*sa,socklen_t salen,
                       char*host,size_t hostlen,
                       char*serv,size_t servlen,int flags);

DESCRIPTION
       The  getnameinfo(3)  function  is  defined   for   protocol-independent
       address-to-nodename  translation.   It  combines  the  functionality of
       gethostbyaddr(3) and getservbyport(3) and  is  the  inverse  of  getad-
       drinfo(3).   The  sa  argument is a pointer to a generic socket address
       structure (of type sockaddr_in or  sockaddr_in6)  of  size  salen  that
       holds  the  input  IP  address and port number.  The arguments host and
       serv are pointers to buffers (of size hostlen and servlen respectively)
       to hold the return values.

       The  caller  can  specify  that  no  hostname  (or  no service name) is
       required by providing a NULL host (or serv) argument or a zero  hostlen
       (or  servlen)  parameter.  However, at least one of hostname or service
       name must be requested.

       The flags argument modifies the behaviour of getnameinfo(3) as follows:

       NI_NOFQDN
              If  set,  return  only  the  hostname part of the FQDN for local
              hosts.

       NI_NUMERICHOST
              If set, then the numeric  form  of  the  hostname  is  returned.
              (When  not  set,  this will still happen in case the node's name
              cannot be looked up.)

       NI_NAMEREQD
              If set, then a error is  returned  if  the  hostname  cannot  be
              looked up.

       NI_NUMERICSERV
              If  set,  then  the service address is returned in numeric form,
              for example by its port number.

       NI_DGRAM
              If set, then the service is datagram  (UDP)  based  rather  than
              stream (TCP) based. This is required for the few ports (512-514)
              that have different services for UDP and TCP.

RETURNVALUE
       On success 0 is returned, and node and service names, if requested, are
       filled with NUL-terminated strings, possibly truncated to fit the spec-
       ified buffer lengths.  On error a nonzero value is returned, and  errno
       is set appropriately.

ERRORS
       EAI_AGAIN
              The name could not be resolved at this time. Try again later.

       EAI_BADFLAGS
              The flags parameter has an invalid value.

       EAI_FAIL
              A non-recoverable error occurred.

       EAI_FAMILY
              The address family was not recognized, or the address length was
              invalid for the specified family.

       EAI_MEMORY
              Out of memory.

       EAI_NONAME
              The  name  does  not  resolve  for  the   supplied   parameters.
              NI_NAMEREQD  is  set  and  the host's name cannot be located, or
              neither hostname nor service name were requested.

       EAI_SYSTEM
              A system error occurred. The error code can be found in errno.

FILES
       /etc/hosts
       /etc/nsswitch.conf
       /etc/resolv.conf

NOTE
       In order to assist the programmer in choosing reasonable sizes for  the
       supplied buffers, <netdb.h> defines the constants
              # define NI_MAXHOST      1025
              # define NI_MAXSERV      32
       The  former  is  the  constant  MAXDNAME  in  recent versions of BIND's
       <arpa/nameser.h> header file. The latter is a guess based on  the  ser-
       vices listed in the current Assigned Numbers RFC.

EXAMPLES
       The  following code tries to get the numeric hostname and service name,
       for a given socket address. Note that there is no  hardcoded  reference
       to a particular address family.

                struct sockaddr *sa;    /* input */
                char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];

                if (getnameinfo(sa, sa->sa_len, hbuf, sizeof(hbuf), sbuf,
                    sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV) == 0)
                        printf("host=%s, serv=%s\n", hbuf, sbuf);

       The  following  version  checks  if  the  socket  address has a reverse
       address mapping.

                struct sockaddr *sa;    /* input */
                char hbuf[NI_MAXHOST];

                if (getnameinfo(sa, sa->sa_len, hbuf, sizeof(hbuf),
                    NULL, 0, NI_NAMEREQD))
                       printf("could not resolve hostname");
                else
                       printf("host=%s\n", hbuf);

CONFORMINGTO
       RFC 2553. (See also XNS, issue 5.2.)

SEEALSO
       getaddrinfo(3), gethostbyaddr(3),  getservbyname(3),  getservbyport(3),
       inet_ntop(3), socket(3), hosts(5), services(5), hostname(7), named(8)

       R.  Gilligan,  S. Thomson, J. Bound and W. Stevens, Basic Socket Inter-
       face Extensions for IPv6, RFC 2553, March 1999.

       Tatsuya Jinmei and Atsushi Onoe, An Extension of Format for IPv6 Scoped
       Addresses,       internet       draft,      work      in      progress.
       ftp://ftp.ietf.org/internet-drafts/draft-ietf-ipngwg-scopedaddr-for-
       mat-02.txt

       Craig Metz, Protocol Independence Using the Sockets API, Proceedings of
       the freenix track: 2000 USENIX annual technical conference, June  2000.
       http://www.usenix.org/publications/library/proceed-
       ings/usenix2000/freenix/metzprotocol.html



Linux Man Page                    2000-12-11                    getnameinfo(3)

CMSG_ALIGNfmodllroundfstrncmp
CMSG_FIRSTHDRfnmatchllroundlstrncpy
CMSG_NXTHDRfopenlocaleconvstrndup
CMSG_SPACEforkptylocaltimestrndupa
MB_CUR_MAXfpathconflockfstrnlen
MB_LEN_MAXfprintflogstrpbrk
__fbufsizefpurgelog10strptime
__flbffputclog1pstrrchr
__fpendingfputc_unlockedlogin_ttystrsep
__fpurgefputslogwtmpstrsignal
__freadablefputs_unlockedlongjmpstrspn
__freadingfputwclrand48strstr
__fsetlockingfputwc_unlockedlrintstrtod
__fwritablefputwslrintfstrtof
__fwritingfputws_unlockedlrintlstrtok
__malloc_hookfreadlroundstrtok_r
__setfpucwfread_unlockedlroundfstrtol
_flushlbffreelroundlstrtold
a64lfreeaddrinfolsearchstrtoll
abortfreehostentmakecontextstrtoq
absfreopenmallocstrtoul
acosfrexpmalloc_hookstrtoull
acoshfscanfmblenstrtouq
addmntentfseekmbrlenstrverscmp
allocafseekombrtowcstrxfrm
alphasortfsetposmbsinitsvc_destroy
argz_addftellmbsnrtowcssvc_freeargs
argz_add_sepftellombsrtowcssvc_getargs
argz_appendftimembstowcssvc_getcaller
argz_countftokmbtowcsvc_getreq
argz_createftrylockfilememalignsvc_getreqset
argz_create_sepftsmemccpysvc_register
argz_deletefts_childrenmemchrsvc_run
argz_extractfts_closememcmpsvc_sendreply
argz_insertfts_openmemcpysvc_unregister
argz_nextfts_readmemfrobsvcerr_auth
argz_replacefts_setmemmemsvcerr_decode
argz_stringifyftwmemmovesvcerr_noproc
asctimefunlockfilememrchrsvcerr_noprog
asinfwidememsetsvcerr_progvers
asinhfwprintfmkdtempsvcerr_systemerr
asprintffwritemkfifosvcerr_weakauth
assertfwrite_unlockedmkstempsvcfd_create
assert_perrorgai_strerrormktempsvcraw_create
atangammamktimesvctcp_create
atan2gammafmodfsvcudp_bufcreate
atanhgammalmpoolsvcudp_create
atexitgcvtmrand48swab
atofget_current_dir_namemtraceswapcontext
atoiget_myaddressmuntraceswprintf
atolgetaddrinfonansysconf
atollgetcnanfsyslog
atoqgetc_unlockednanlsystem
auth_destroygetcharnearbyinttan
authnone_creategetchar_unlockednearbyintftanh
authunix_creategetcwdnearbyintltcdrain
authunix_create_defaultgetdatenetlinktcflow
basenamegetdate_rnextaftertcflush
bcmpgetdelimnextafterftcgetattr
bcopygetdirentriesnextafterltcgetpgrp
bindresvportgetenvnexttowardtcgetsid
bsearchgetfsentnexttowardftcsendbreak
bstringgetfsfilenexttowardltcsetattr
btowcgetfsspecnftwtcsetpgrp
btreegetgrentnl_langinfotdelete
byteordergetgrgidnrand48telldir
bzerogetgrnamntohltempnam
callocgethostbyaddrntohstermios
callrpcgethostbynameon_exittfind
catclosegethostbyname2opendirtgamma
catgetsgethostbyname2_ropenlogtgammaf
catopengethostbyname_ropenptytgammal
cbrtgetipnodebyaddrpathconftimegm
ceilgetipnodebynamepclosetimelocal
ceilfgetlineperrortmpfile
ceillgetloadavgpmap_getmapstmpnam
cfgetispeedgetloginpmap_getporttoascii
cfgetospeedgetmntentpmap_rmtcalltolower
cfmakerawgetnameinfopmap_settoupper
cfsetispeedgetnetbyaddrpmap_unsettowctrans
cfsetospeedgetnetbynamepopentowlower
clearenvgetnetentposix_memaligntowupper
clearerrgetoptpowtrunc
clearerr_unlockedgetopt_longprintftruncf
clnt_broadcastgetopt_long_onlyprofiltruncl
clnt_callgetpasspsignaltsearch
clnt_controlgetprotobynameptsnamettyname
clnt_creategetprotobynumberputcttyname_r
clnt_destroygetprotoentputc_unlockedttyslot
clnt_freeresgetptputchartwalk
clnt_geterrgetpwputchar_unlockedtzset
clnt_pcreateerrorgetpwentputenvulimit
clnt_perrnogetpwnamputpwentundocumented
clnt_perrorgetpwuidputsungetc
clnt_spcreateerrorgetrpcbynamepututlineungetwc
clnt_sperrnogetrpcbynumberpututxlineunlocked_stdio
clnt_sperrorgetrpcentputwunlockpt
clntraw_creategetrpcportputwcunsetenv
clnttcp_creategetsputwc_unlockedupdwtmp
clntudp_bufcreategetservbynameputwcharusleep
clntudp_creategetservbyportputwchar_unlockedutmpname
clockgetserventqecvtva_arg
closedirgetttyentqecvt_rva_end
closeloggetttynamqfcvtva_start
cmsggetumaskqfcvt_rvalloc
confstrgetusershellqgcvtvasprintf
copysigngetutentqsortvdprintf
copysignfgetutidqueueverr
copysignlgetutlineraiseverrx
cosgetutxentrandversionsort
coshgetutxidrandomvfprintf
cryptgetutxlinercmdvfscanf
ctermidgetwre_compvfwprintf
ctimegetwcre_execvprintf
cuseridgetwc_unlockedreaddirvscanf
daemongetwcharreallocvsnprintf
dbgetwchar_unlockedrealpathvsprintf
dbopengetwdrecnovsscanf
difftimeglobregcompvswprintf
dirfdglobfreeregerrorvsyslog
dirnamegmtimeregexvwarn
divgrantptregexecvwarnx
dlclosegsignalregfreevwprintf
dlerrorhashregisterrpcwarn
dlopenhasmntoptremovewarnx
dlsymhcreateremquewcpcpy
dn_comphcreate_rres_initwcpncpy
dn_expandhdestroyres_mkquerywcrtomb
dprintfhdestroy_rres_querywcscasecmp
drand48herrorres_querydomainwcscat
dremhsearchres_searchwcschr
dysizehsearch_rres_sendwcscmp
ecvthstrerrorresolverwcscpy
ecvt_rhtonlrewindwcscspn
encrypthtonsrewinddirwcsdup
endfsenthypotrindexwcslen
endgrenticonvrintwcsncasecmp
endhostenticonv_closerintfwcsncat
endmntenticonv_openrintlwcsncmp
endnetentimaxabsroundwcsncpy
endprotoentindexroundfwcsnlen
endpwentinetroundlwcsnrtombs
endrpcentinet_addrrpcwcspbrk
endserventinet_atonrresvportwcsrchr
endttyentinet_lnaofrtnetlinkwcsrtombs
endusershellinet_makeaddrruserokwcsspn
endutentinet_netofscandirwcsstr
endutxentinet_networkscanfwcstok
envz_addinet_ntoaseed48wcstombs
envz_entryinet_ntopseekdirwcswidth
envz_getinet_ptonsetbufwctob
envz_mergeinfnansetbufferwctomb
envz_removeinitgroupssetenvwctrans
envz_stripinitstatesetfsentwctype
erand48insquesetgrentwcwidth
erfintrosethostentwmemchr
erfciruseroksetjmpwmemcmp
errisalnumsetkeywmemcpy
errnoisalphasetlinebufwmemmove
errxisasciisetlocalewmemset
ether_atonisattysetlogmaskwprintf
ether_aton_risblanksetmntentxdr
ether_hosttoniscntrlsetnetentxdr_accepted_reply
ether_lineisdigitsetprotoentxdr_array
ether_ntoaisgraphsetpwentxdr_authunix_parms
ether_ntoa_risinfsetrpcentxdr_bool
ether_ntohostislowersetserventxdr_bytes
execisnansetstatexdr_callhdr
execlisprintsetttyentxdr_callmsg
execleispunctsetusershellxdr_char
execlpisspacesetutentxdr_destroy
execvisuppersetutxentxdr_double
execvpiswalnumsetvbufxdr_enum
exitiswalphashm_openxdr_float
expiswblanksigaddsetxdr_free
expm1iswcntrlsigdelsetxdr_getpos
fabsiswctypesigemptysetxdr_inline
fabsfiswdigitsigfillsetxdr_int
fabsliswgraphsiginterruptxdr_long
fcloseiswlowersigismemberxdr_opaque
fclosealliswprintsiglongjmpxdr_opaque_auth
fcvtiswpunctsignbitxdr_pmap
fcvt_riswspacesigsetjmpxdr_pmaplist
fdopeniswuppersigsetopsxdr_pointer
feclearexceptiswxdigitsinxdr_reference
fegetenvisxdigitsinhxdr_rejected_reply
fegetexceptflagj0sleepxdr_replymsg
fegetroundj0fsnprintfxdr_setpos
feholdexceptj0lsprintfxdr_short
fenvj1sqrtxdr_string
feofj1fsrandxdr_u_char
feof_unlockedj1lsrand48xdr_u_int
feraiseexceptjnsrandomxdr_u_long
ferrorjnfsscanfxdr_u_short
ferror_unlockedjnlssignalxdr_union
fesetenvjrand48stdargxdr_vector
fesetexceptflagkey_decryptsessionstderrxdr_void
fesetroundkey_encryptsessionstdinxdr_wrapstring
fetestexceptkey_gendesstdioxdrmem_create
feupdateenvkey_secretkey_is_setstdio_extxdrrec_create
fflushkey_setsecretstdoutxdrrec_endofrecord
fflush_unlockedkillpgstpcpyxdrrec_eof
ffsklogctlstpncpyxdrrec_skiprecord
fgetcl64astrcasecmpxdrstdio_create
fgetc_unlockedlabsstrcatxprt_register
fgetgrentlcong48strchrxprt_unregister
fgetposldexpstrcmpy0
fgetpwentldivstrcolly0f
fgetslfindstrcpyy0l
fgets_unlockedlgammastrcspny1
fgetwclgamma_rstrdupy1f
fgetwc_unlockedlgammafstrdupay1l
fgetwslgammaf_rstrerroryn
fgetws_unlockedlgammalstrerror_rynf
filenolgammal_rstrfmonynl
fileno_unlockedllabsstrfry 
finitelldivstrftime 
flockfilellrintstring 
floorllrintfstrlen 
floorfllrintlstrncasecmp 


Inkscape 0.47
Vector graphic editor for SVG
DeleGate 9.9.6-pre5
Proxy server which runs on multiple platforms
Nano 2.1.99pre2
Emulate Pico while also offering a few enhancements.
My Money 2.0.49
Personal financial software
Linux Kernel 2.6 2.6.32-rc8
Linux Kernel
GCstar 1.5.0
Personal collections manager
ImageMagick 6.5.7.9
ImageMagick image processing studio
BibleTime 2.4
Bible study software for Linux / KDE
Tellico 2.1.1
Collection manager for books, music, videos, and bibliographies
Totem 2.28.4
Movie player for Gnome
Free IT Magazines, White Papers, eBooks, and more !
Oracle Magazine

Contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more.

Vulnerability Management for Dummies

Get all the Facts and See How to Implement a Successful Vulnerability Management Program.

Website Magazine

Has tapped premier talent in the Internet industry for our content and each and every issue will contain practical advice and insights for website owners.

Linux Software Map
Find Linux RPM
Best Rated Linux Software
Most Rated Linux Software
Linux Distributions
Linux Howtos
Quick Survey

Please take our survey and help us improve our website to serve you better.

Thank you.
Linux Software
Linux / IT Resources
Site Resources
Google
Privacy Policy
Contact Us
Submit Software
Advertising info