service
|
 |
Most hosts on the Internet
provide a set of standard services via some well-known numbered ports. Each
service has a description, a set of aliases, a port number, and a protocol
description (either tcp or udp
). Information about these services is typically stored in the /etc/services
directory for UNIX and in the \windows\services directory for Win32.
An os_service
can be constructed from a description/protocol pair or a port/protocol pair.
Most services can be accessed via either tcp or udp
protocols.
Declaration
#include <ospace/socket/service.h>
class os_service;
Interface
Constructor
os_service()
Constructs
a default service object.
Constructor
os_service(
const string& name ,
const string& protocol )
Constructs
a service with name and
protocol (default tcp ).
Throws: os_network_toolkit_error
Constructor
os_service(
int port ,
const string& protocol )
Constructs
a service with port and protocol
(default tcp ).
Throws: os_network_toolkit_error
Constructor
os_service(
const servent& service )
Constructs
a service from the servent structure service
.
Constructor
os_service(
const os_service& service )
Constructs
a service with the value service .
Throws: os_network_toolkit_error
<
bool
operator< ( const os_service& service
)
const
Returns
true if this service is less than service
.
=
os_service&
operator=( const os_service& service )
Assigns
this service the value service .
==
bool
operator==( const os_service& service )
const
Returns
true if this service is the same as service
.
aliases
const
vector< string >& aliases() const
Returns
a vector of service aliases.
defined
bool
defined() const
Returns
true if this service name is not empty.
name
string
name() const
Returns
the service name.
port
int
port() const
Returns
the service port.
print
void
print( ostream& stream )
const
Prints
the service name, port, and protocol to stream .
protocol
string
protocol() const
Returns
the service protocol.
UNIX-Specific Interface
services
/*
static */ vector< os_service* > services()
Returns
a vector of pointers to objects on the heap that represents all services in
the service database. The caller is responsible for proper deletion of
objects in the vector.
Non-Member Functions
<<
ostream&
operator<<( ostream& stream ,
const os_service& service )
Prints service
to stream .
Universal Streaming Service
#include <ospace/uss/network.h>
<<
os_bstream&
operator<<( os_bstream& stream ,
const os_service& service )
Writes service
to stream .
>>
os_bstream&
operator>>( os_bstream& stream ,
os_service& service )
Reads service
from stream .
Copyright©1994-2026 Recursion
Software LLC
All Rights Reserved - For use by licensed users only.