Chapter Contents |
Previous |
Next |
getservbyport |
Portability: | UNIX compatible |
SYNOPSIS | |
DESCRIPTION | |
RETURN VALUE | |
CAUTION | |
PORTABILITY | |
IMPLEMENTATION | |
RELATED FUNCTIONS |
SYNOPSIS |
#include <netdb.h> struct servent *getservbyport(int port, const char *proto);
DESCRIPTION |
Given the port of a well-known service,
identified by the
port
argument, and the protocol string for accessing it, pointed to by
proto
,
getservbyport
returns a pointer to the
servent
structure, which is defined in
<netdb.h>
. This structure is typically used to obtain the name of
the service from the
s_name
field. The source of the data in this structure is the services file, that
is, a file with the same format as the
/etc/services
file on a UNIX operating system. Refer to <netdb.h> for details on the
servent
structure.
Refer to Search Logic for information on the logic used to determine the location of the services file.
RETURN VALUE |
If
getservbyport
succeeds, it returns a pointer to the matching port number
in the
servent
structure.
A null pointer indicates an error occurred or there were no more network entries.
CAUTION |
The value that
getservbyport
returns points to a static structure within the library.
You must copy the information from this structure before you make further
getservbname
,
getservbyport
, or
getservent
calls.
PORTABILITY |
getservbyport
is portable to other environments, including most UNIX
systems, that implement BSD sockets.
IMPLEMENTATION |
getservbyport
is ported directly from the BSD UNIX Socket Library.
RELATED FUNCTIONS |
endservent
,
setservent
,
getservent
,
getservbyname
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.