Rudiments
Public Member Functions | Static Public Member Functions | List of all members
serviceentry Class Reference

Inherits object.

Public Member Functions

 serviceentry ()
 
 ~serviceentry ()
 
bool open (const char *servicename, const char *protocol)
 
bool open (int32_t port, const char *protocol)
 
const char * getName ()
 
int32_t getPort ()
 
const char * getProtocol ()
 
const char *const * getAliasList ()
 
- Public Member Functions inherited from object
virtual ~object ()
 

Static Public Member Functions

static int32_t getPort (const char *servicename, const char *protocol)
 
static char * getName (int32_t port, const char *protocol)
 
static bool getNeedsMutex ()
 
static void setMutex (threadmutex *mtx)
 

Detailed Description

The serviceentry class provides methods for retrieving entries from the service file (/etc/services on unix).

Constructor & Destructor Documentation

◆ serviceentry()

serviceentry::serviceentry ( )

Creates an instance of the serviceentry class.

◆ ~serviceentry()

serviceentry::~serviceentry ( )

Deletes this instance of the serviceentry class.

Member Function Documentation

◆ getAliasList()

const char* const* serviceentry::getAliasList ( )

Returns a NULL-terminated list of aliases for the service entry.

◆ getName() [1/2]

const char* serviceentry::getName ( )

Returns the name of the service entry.

◆ getName() [2/2]

static char* serviceentry::getName ( int32_t  port,
const char *  protocol 
)
static

Convenience method. Sets "name" to the name of the service that a server listening on "port", using "protocol" (tcp, udp, etc.) would be serving. Note that "name" is allocated internally and returned. The calling program must free the buffer.

Note that the return value is allocated internally and returned. The calling program must free the buffer.

Returns NULL if an error occurred or one of the paramters was invalid.

◆ getNeedsMutex()

static bool serviceentry::getNeedsMutex ( )
static

Returns true if this class needs a mutex to operate safely in a threaded environment and false otherwise.

◆ getPort() [1/2]

int32_t serviceentry::getPort ( )

Returns the port that a server for this service entry would listen on.

◆ getPort() [2/2]

static int32_t serviceentry::getPort ( const char *  servicename,
const char *  protocol 
)
static

Convenience method. Returns the port that the server for "servicename" using "protocol" (tcp, udp, etc.) would listen on.

Returns -1 if an error occurred or one of the paramters was invalid.

◆ getProtocol()

const char* serviceentry::getProtocol ( )

Returns the protocol (tcp, udp, etc.) for this service entry.

◆ open() [1/2]

bool serviceentry::open ( const char *  servicename,
const char *  protocol 
)

Opens a service entry by "servicename" and "protocol" (tcp, udp, etc.). Returns true on success and false on failure.

◆ open() [2/2]

bool serviceentry::open ( int32_t  port,
const char *  protocol 
)

Opens a service entry by the "port" that a server for would listen on and the "protocol" that it would use (tcp, udp, etc.). Returns true on success and false on failure.

◆ setMutex()

static void serviceentry::setMutex ( threadmutex mtx)
static

Allows you to supply a mutex is the class needs it. (see getNeedsMutex()). If your application is not multithreaded, then there is no need to supply a mutex.