ggeettsseerrvvbbyyppoorrtt() -- Sockets Function (libsocket)

Get a service entry by port number
#iinncclluuddee <nneettddbb.hh>
ssttrruucctt sseerrvveenntt *ggeettsseerrvvbbyyppoorrtt(_p_o_r_t, _p_r_o_t_o_c_o_l);
iinntt _p_o_r_t; cchhaarr *_p_r_o_t_o_c_o_l;

Function ggeettsseerrvvbbyyppoorrtt()  searches file /eettcc/sseerrvviicceess,  which describes the
services offered by TCP/IP on  your local network, for the services offered
by _p_o_r_t. If  _p_r_o_t_o_c_o_l is not NULL, the search  must also match the protocol
it  names.   /eettcc/sseerrvviicceess  must  first  have  been opened  by  a  call  to
sseettsseerrvveenntt().

ggeettsseerrvvbbyyppoorrtt() returns a pointer to  a structure of type sseerrvveenntt, which is
defined in header file <nneettddbb.hh>:

struct servent {
    char *s_name;   /* official name of service */
    char **s_aliases;   /* alias list */
    int s_port; /* port service resides at */
    char *s_proto;  /* protocol to use */
};

The following details each member:

ss_nnaammee
     The official name of the service.

ss_aalliiaasseess
     This  points to  a  zero-terminated list  of alternate  names for  the
     service.

ss_ppoorrtt
     The  port  number at  which  the service  resides.   Port numbers  are
     returned in network byte order.

ss_pprroottoo
     The name of the protocol to use when contacting the service.

To close /eettcc/sseerrvviicceess, call function eennddsseerrvveenntt().

ggeettsseerrvvbbyyppoorrtt() returns  NULL if an  error occurs, or if  it encounters the
end of the file.

_S_e_e _A_l_s_o
eennddsseerrvveenntt(),   ggeettsseerrvvbbyyeenntt(),    ggeettsseerrvvbbyynnaammee(),   lliibbssoocckkeett,   nneettddbb.hh,
sseettsseerrvveenntt(),

_N_o_t_e_s
This function uses a static data  space.  If your application needs to save
these data, it must copy them before any subsequent calls overwrite them.
