Base Framework
Public Member Functions | Static Public Member Functions | List of all members
InetService Class Reference

Internet Protocol service. More...

#include <base/net/InetService.h>

Inherits Object.

Public Member Functions

 InetService (const String &name, const String &protocol=Literal("tcp"))
 
 InetService (unsigned short port, const String &protocol=Literal("tcp"))
 
 InetService (const InetService &copy) noexcept
 
InetServiceoperator= (const InetService &assign) noexcept
 
const StringgetName () const noexcept
 
unsigned short getPort () const noexcept
 
const StringgetProtocol () const noexcept
 

Static Public Member Functions

static unsigned short getByName (const String &name, const String &protocol) noexcept
 
static String getByPort (unsigned short port, const String &protocol) noexcept
 

Detailed Description

Internet Protocol service.

This class represents an internet service.

Version
1.0
Examples
testsuite/echod.cpp, testsuite/ping.cpp, and testsuite/server.cpp.

Constructor & Destructor Documentation

◆ InetService() [1/3]

InetService::InetService ( const String name,
const String protocol = Literal("tcp") 
)
explicit

Initializes a service object by specified service name and protocol.

Parameters
nameSpecifies the name of the service.
protocolSpecifies the name of the protocol. Default is "tcp".

◆ InetService() [2/3]

InetService::InetService ( unsigned short  port,
const String protocol = Literal("tcp") 
)
explicit

Initializes a service object by specified port number and protocol.

Parameters
portThe port number.
protocolSpecifies the name of the protocol. Default is "tcp".

◆ InetService() [3/3]

InetService::InetService ( const InetService copy)
noexcept

Copy constructor.

Member Function Documentation

◆ getByName()

static unsigned short InetService::getByName ( const String name,
const String protocol 
)
staticnoexcept

Returns the port number of the service given by the service name and protocol.

Parameters
nameSpecifies the name of the service.
protocolSpecifies the name of the protocol. Default is "tcp".
Returns
0 if the service was not found.

◆ getByPort()

static String InetService::getByPort ( unsigned short  port,
const String protocol 
)
staticnoexcept

Returns the name of the service given by the specified port and protocol.

Parameters
portSpecifies the port number.
protocolSpecifies the name of the protocol. Default is "tcp".
Returns
Empty string if service was not found.

◆ getName()

const String& InetService::getName ( ) const
noexcept

Returns the name of the service.

Examples
testsuite/server.cpp.

◆ getPort()

unsigned short InetService::getPort ( ) const
noexcept

Returns the port associated with the service.

Examples
testsuite/ping.cpp, and testsuite/server.cpp.

◆ getProtocol()

const String& InetService::getProtocol ( ) const
noexcept

Returns the protocol of the service.

Examples
testsuite/server.cpp.

◆ operator=()

InetService& InetService::operator= ( const InetService assign)
noexcept

Assignment operator.