VMS Help
TCPIP Services, Programming Interfaces, Sockets API, getservbyport()

 *Conan The Librarian (sorry for the slow response - running on an old VAX)

    Gets information on the specified port from the network services
    database.
    Format
      #include  <netdb.h>
      struct servent *getservbyport  ( int port, char *proto );

  1 - Arguments

 port
    The port number for which to search. This port number should be
    specified in network byte order.
 proto
    A pointer to a string containing the name of the protocol (TCP or
    UDP) for which to search.

  2 - Description

    This function searches sequentially from the beginning of the
    file until a matching port is found, or until end of file is
    encountered. If a protocol name is also supplied, searches must
    also match the protocol.
    This function returns a pointer to a servent structure containing
    the broken-out fields of the requested line in the network
    services database:
    struct  servent {
            char    *s_name;        /* official name of service */
            char    **s_aliases;    /* alias list */
            long    s_port;         /* port service resides at */
            char    *s_proto;       /* protocol to use */
    };
    The members of this structure are:
    s_name             The official name of the service.
    s_aliases          A zero-terminated list of alternate names for
                       the service.
    s_port             The port number at which the service resides.
                       Port numbers are returned in network byte
                       order.
    s_proto            The name of the protocol to use when
                       contacting the service.
    All information is contained in a static area, so it must be
    copied to be saved.
    Related Functions
    See also getservbyname().

  3 - Return Values

    NULL               Indicates end of file or an error.
    x                  A pointer to a servent structure.
  Close     HLB-list     TLB-list     Help  

[legal] [privacy] [GNU] [policy] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.