getservbyport man page on DigitalUNIX

Man page or keyword search:  
man Server   12896 pages
apropos Keyword Search (all sections)
Output format
DigitalUNIX logo
[printable version]

getservbyport(3)					      getservbyport(3)

       getservbyport, getservbyport_r - Get a service entry by port number

       #include <netdb.h>

       struct servent *getservbyport(
	       int port,
	       const char *proto );

       [Tru64  UNIX]  The following obsolete function is supported in order to
       maintain backward compatibility with previous versions of the operating
       system.	You should not use it in new designs.  int getservbyport_r(
	       int port,
	       const char *proto,
	       struct servent *serv,
	       struct servent_data *serv_data );

       Standard C Library (libc)

       Interfaces  documented on this reference page conform to industry stan‐
       dards as follows:

       getservbyport():	 XNS4.0, XNS5.0

       Refer to the standards(5) reference page	 for  more  information	 about
       industry standards and associated tags.

       Specifies  the  port number where the service is located. This argument
       must be converted from host-byte order to  a  2-byte  Internet  network
       integer through a call to the htons() function.	Specifies the protocol
       name to use when contacting the service.	 [Tru64 UNIX]  For  getservby‐
       port_r()	 only,	this  points  to  the  servent structure.  The netdb.h
       header file defines the	servent	 structure.   [Tru64  UNIX]  For  get‐
       servbyport_r()  only,  this  is	data  for  the services database.  The
       netdb.h header file defines the servent_data structure.

       The getservbyport() function returns a pointer to a structure  of  type
       servent.	 Its  members  specify	data  in  fields from a record line in
       either the local /etc/services file or the NIS distributed network ser‐
       vices database file. To determine which file or files to search, and in
       which order, the system uses the switches in  the  /etc/svc.conf	 file.
       The netdb.h header file defines the servent structure.

       The  getservbyport()  function  searches	 the network services database
       file sequentially until a match with the port parameter	and  with  the
       proto parameter occurs. When used, the proto parameter must specify the
       network services protocol name. When the protocol name is not specified
       (the  proto parameter is NULL), the proto parameter need not be matched
       during the network services database file record search. When EOF (End-
       of-File) is reached without a match, a null pointer is returned by this

       Use the endservent() function to close the  network  services  database

       The getservbyport() function returns a pointer to thread-specific data.
       Subsequent calls to this or a related function  from  the  same	thread
       overwrite this data.

       [Tru64  UNIX]  The  getservbyport_r() function is an obsolete reentrant
       version of the getservbyport() function.	 It is supported in  order  to
       maintain backward compatibility with previous versions of the operating
       system and should not be used in new designs.  Note that you must zero-
       fill  the  servent_data structure before its first access by either the
       setservent_r() or getservbyport_r() function.

       Upon successful completion,  the	 getservbyport()  function  returns  a
       pointer	to a servent structure.	 If it fails or reaches the end of the
       network services database file, it returns a null pointer.

       [Tru64 UNIX]  Upon successful completion, the  getservbyport_r()	 func‐
       tion  stores  the servent structure in the location pointed to by serv,
       and returns a value of 0 (zero).	 Upon failure, it returns a  value  of

       [Tru64 UNIX]  If any of the following conditions occurs, the getservby‐
       port_r() function sets errno to the corresponding value:

       The serv or serv_data parameter is invalid.  The search failed.

       In addition, if the function fails to open the file, it sets  errno  to
       indicate the cause of the failure.

       The  Internet  network  service	name database file. Each record in the
       file occupies a single line and has four fields: the  official  service
       name,  the  port	 number, the protocol name, and aliases.  The database
       service selection configuration file.

       Functions:  getservbyname(3),  getservent(3),  setservent(3),   endser‐

       Files: services(4), svc.conf(4).

       Networks: nis_intro(7).

       Standards: standards(5).

       Network Programmer's Guide


List of man pages available for DigitalUNIX

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
Vote for polarhome
Free Shell Accounts :: the biggest list on the net