TSDuck Version 3.32-2780 (TSDuck - The MPEG Transport Stream Toolkit)
ts::TelnetConnection Class Reference

Implementation of a half-duplex line oriented telnet connection. More...

Inheritance diagram for ts::TelnetConnection:
Collaboration diagram for ts::TelnetConnection:

Public Types

typedef TCPConnection SuperClass
 Reference to the superclass.
 

Public Member Functions

 TelnetConnection (const std::string &prompt=std::string())
 Constructor. More...
 
virtual ~TelnetConnection () override
 Virtual destructor.
 
bool bind (const IPv4SocketAddress &addr, Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance()))))
 Bind to a local address and port. More...
 
virtual bool close (Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance())))) override
 Close the socket. More...
 
bool closeWriter (Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance()))))
 Close the write direction of the connection. More...
 
bool connect (const IPv4SocketAddress &addr, Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance()))))
 Connect to a remote address and port. More...
 
bool debug () const
 Check if debugging is active. More...
 
void debug (const UChar *fmt, std::initializer_list< ArgMixIn > args)
 Report a debug message with a printf-like interface. More...
 
void debug (const UString &fmt, std::initializer_list< ArgMixIn > args)
 Report a debug message with a printf-like interface. More...
 
void debug (const UString &msg)
 Report a debug message. More...
 
bool disconnect (Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance()))))
 Disconnect from remote partner. More...
 
void error (const UChar *fmt, std::initializer_list< ArgMixIn > args)
 Report an error message with a printf-like interface. More...
 
void error (const UString &fmt, std::initializer_list< ArgMixIn > args)
 Report an error message with a printf-like interface. More...
 
void error (const UString &msg)
 Report an error message. More...
 
void fatal (const UChar *fmt, std::initializer_list< ArgMixIn > args)
 Report a fatal error message with a printf-like interface. More...
 
void fatal (const UString &fmt, std::initializer_list< ArgMixIn > args)
 Report a fatal error message with a printf-like interface. More...
 
void fatal (const UString &msg)
 Report a fatal error message. More...
 
bool getLocalAddress (IPv4SocketAddress &addr, Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance()))))
 Get local socket address. More...
 
bool getPeer (IPv4SocketAddress &addr, Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance())))) const
 Get the connected remote peer. More...
 
SysSocketType getSocket () const
 Get the underlying socket device handle (use with care). More...
 
bool gotErrors () const
 Check if errors (or worse) were reported through this object. More...
 
void info (const UChar *fmt, std::initializer_list< ArgMixIn > args)
 Report an informational message with a printf-like interface. More...
 
void info (const UString &fmt, std::initializer_list< ArgMixIn > args)
 Report an informational message with a printf-like interface. More...
 
void info (const UString &msg)
 Report an informational message. More...
 
bool isConnected () const
 Check if the socket is connected. More...
 
bool isOpen () const
 Check if socket is open. More...
 
virtual void log (int severity, const UChar *fmt, std::initializer_list< ArgMixIn > args)
 Report a message with an explicit severity and a printf-like interface. More...
 
virtual void log (int severity, const UString &fmt, std::initializer_list< ArgMixIn > args)
 Report a message with an explicit severity and a printf-like interface. More...
 
virtual void log (int severity, const UString &msg)
 Report a message with an explicit severity. More...
 
int maxSeverity () const
 Get maximum severity level. More...
 
virtual bool open (Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance())))) override
 Open the socket. More...
 
UString peerName () const
 Get the connected remote peer as a string. More...
 
virtual void raiseMaxSeverity (int level)
 Raise maximum severity level. More...
 
bool receive (std::string &data, const AbortInterface *abort, Report &report)
 Receive character data. More...
 
bool receive (UString &data, const AbortInterface *abort, Report &report)
 Receive character data. More...
 
bool receive (void *buffer, size_t max_size, size_t &ret_size, const AbortInterface *abort=nullptr, Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance()))))
 Receive data. More...
 
bool receive (void *buffer, size_t size, const AbortInterface *abort=nullptr, Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance()))))
 Receive data until buffer is full. More...
 
bool receiveLine (std::string &line, const AbortInterface *abort, Report &report)
 Receive a line. More...
 
bool receiveLine (UString &line, const AbortInterface *abort, Report &report)
 Receive a line. More...
 
void resetErrors ()
 Reset the error indicator. More...
 
bool reusePort (bool reuse_port, Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance()))))
 Set the "reuse port" option. More...
 
bool send (const std::string &str, Report &report)
 Send a string to the server. More...
 
bool send (const UString &str, Report &report)
 Send a string to the server. More...
 
bool send (const void *data, size_t size, Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance()))))
 Send data. More...
 
bool sendLine (const std::string &str, Report &report)
 Send a text line to the server. More...
 
bool sendLine (const UString &str, Report &report)
 Send a text line to the server. More...
 
bool setKeepAlive (bool active, Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance()))))
 Set the "keep alive" option. More...
 
bool setLingerTime (int seconds, Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance()))))
 Set the linger time option. More...
 
virtual void setMaxSeverity (int level)
 Set maximum severity level. More...
 
bool setNoDelay (bool active, Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance()))))
 Set the "no delay" option. More...
 
bool setNoLinger (Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance()))))
 Remove the linger time option. More...
 
bool setReceiveBufferSize (size_t size, Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance()))))
 Set the receive buffer size. More...
 
bool setReceiveTimeout (MilliSecond timeout, Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance()))))
 Set the receive timeout. More...
 
bool setSendBufferSize (size_t size, Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance()))))
 Set the send buffer size. More...
 
bool setTTL (int ttl, Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance()))))
 Set the Time To Live (TTL) option. More...
 
void severe (const UChar *fmt, std::initializer_list< ArgMixIn > args)
 Report a severe error message with a printf-like interface. More...
 
void severe (const UString &fmt, std::initializer_list< ArgMixIn > args)
 Report a severe error message with a printf-like interface. More...
 
void severe (const UString &msg)
 Report a severe error message. More...
 
bool verbose () const
 Check if verbose reporting is active. More...
 
void verbose (const UChar *fmt, std::initializer_list< ArgMixIn > args)
 Report a verbose message with a printf-like interface. More...
 
void verbose (const UString &fmt, std::initializer_list< ArgMixIn > args)
 Report a verbose message with a printf-like interface. More...
 
void verbose (const UString &msg)
 Report a verbose message. More...
 
bool waitForPrompt (const AbortInterface *abort, Report &report)
 Receive a prompt. More...
 
void warning (const UChar *fmt, std::initializer_list< ArgMixIn > args)
 Report a warning message with a printf-like interface. More...
 
void warning (const UString &fmt, std::initializer_list< ArgMixIn > args)
 Report a warning message with a printf-like interface. More...
 
void warning (const UString &msg)
 Report a warning message. More...
 

Static Public Attributes

static const std::string EOL
 A telnet end-of-line sequence.
 

Protected Member Functions

bool createSocket (int domain, int type, int protocol, Report &report)
 Create the socket. More...
 
virtual void declareOpened (SysSocketType sock, Report &report) override
 Set an open socket descriptor from a subclass. More...
 
virtual void handleClosed (Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance())))) override
 This virtual method can be overriden by subclasses to be notified of close. More...
 
virtual void handleConnected (Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance()))))
 This virtual method can be overriden by subclasses to be notified of connection. More...
 
virtual void handleDisconnected (Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance()))))
 This virtual method can be overriden by subclasses to be notified of disconnection. More...
 
virtual void handleOpened (Report &report)
 This virtual method can be overriden by subclasses to be notified of open. More...
 
virtual void writeLog (int severity, const UString &msg) override
 Actual message reporting method. More...
 

Protected Attributes

volatile int _max_severity
 Debug level is accessible to subclasses.
 
Mutex _mutex
 Mutex protecting this object.
 

Detailed Description

Implementation of a half-duplex line oriented telnet connection.

This class supports the communication with a half-duplex line oriented telnet server:

  • The server sends a prompt.
  • The client sends a request.
  • The server replies by one or more lines followed by the prompt.

From the client point of view the interface must allow:

  • To send a request.
  • To get replies line until all the lines of the replies have been read.

This class is also a subclass of Report, allowing it to be used to end log messages.

Constructor & Destructor Documentation

◆ TelnetConnection()

ts::TelnetConnection::TelnetConnection ( const std::string &  prompt = std::string())

Constructor.

Parameters
[in]promptPrompt string to send to the client.

Member Function Documentation

◆ send() [1/3]

bool ts::TelnetConnection::send ( const std::string &  str,
Report report 
)

Send a string to the server.

Parameters
[in]strThe string to send to the server.
[in,out]reportWhere to report errors.
Returns
True on success, false on error.

◆ send() [2/3]

bool ts::TelnetConnection::send ( const UString str,
Report report 
)

Send a string to the server.

Parameters
[in]strThe string to send to the server.
[in,out]reportWhere to report errors.
Returns
True on success, false on error.

◆ sendLine() [1/2]

bool ts::TelnetConnection::sendLine ( const std::string &  str,
Report report 
)

Send a text line to the server.

Parameters
[in]strThe line to send to the server.
[in,out]reportWhere to report errors.
Returns
True on success, false on error.

◆ sendLine() [2/2]

bool ts::TelnetConnection::sendLine ( const UString str,
Report report 
)

Send a text line to the server.

Parameters
[in]strThe line to send to the server.
[in,out]reportWhere to report errors.
Returns
True on success, false on error.

◆ receive() [1/4]

bool ts::TelnetConnection::receive ( std::string &  data,
const AbortInterface abort,
Report report 
)

Receive character data.

Parameters
[out]dataThe received data.
[in]abortIf non-zero, invoked when I/O is interrupted (in case of user-interrupt, return, otherwise retry).
[in,out]reportWhere to report errors.
Returns
True on success, false on error. Return true until the last line of the replies has been received.

◆ receive() [2/4]

bool ts::TelnetConnection::receive ( UString data,
const AbortInterface abort,
Report report 
)

Receive character data.

Parameters
[out]dataThe received data.
[in]abortIf non-zero, invoked when I/O is interrupted (in case of user-interrupt, return, otherwise retry).
[in,out]reportWhere to report errors.
Returns
True on success, false on error. Return true until the last line of the replies has been received.

◆ receiveLine() [1/2]

bool ts::TelnetConnection::receiveLine ( std::string &  line,
const AbortInterface abort,
Report report 
)

Receive a line.

Parameters
[out]lineThe received line.
[in]abortIf non-zero, invoked when I/O is interrupted (in case of user-interrupt, return, otherwise retry).
[in,out]reportWhere to report errors.
Returns
True on success, false on error. Return true until the last line of the replies has been received.

◆ receiveLine() [2/2]

bool ts::TelnetConnection::receiveLine ( UString line,
const AbortInterface abort,
Report report 
)

Receive a line.

Parameters
[out]lineThe received line.
[in]abortIf non-zero, invoked when I/O is interrupted (in case of user-interrupt, return, otherwise retry).
[in,out]reportWhere to report errors.
Returns
True on success, false on error. Return true until the last line of the replies has been received.

◆ waitForPrompt()

bool ts::TelnetConnection::waitForPrompt ( const AbortInterface abort,
Report report 
)

Receive a prompt.

Do not wait if the prompt is empty.

Parameters
[in]abortIf non-zero, invoked when I/O is interrupted (in case of user-interrupt, return, otherwise retry).
[in,out]reportWhere to report errors.
Returns
True on success, false on error.

◆ writeLog()

virtual void ts::TelnetConnection::writeLog ( int  severity,
const UString msg 
)
overrideprotectedvirtual

Actual message reporting method.

Must be implemented in actual classes. The method is called only when a message passed the severity filter. It is not necessary to recheck severity inside the method.

Parameters
[in]severityMessage severity.
[in]msgMessage text.

Implements ts::Report.

◆ connect()

bool ts::TCPConnection::connect ( const IPv4SocketAddress addr,
Report report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))) 
)
inherited

Connect to a remote address and port.

Use this method when acting as TCP client. Do not use on server side: the TCPConnection object is passed to TCPServer::accept() which establishes the connection.

Parameters
[in]addrIP address and port of the server to connect.
[in,out]reportWhere to report error.
Returns
True on success, false on error.

◆ isConnected()

bool ts::TCPConnection::isConnected ( ) const
inlineinherited

Check if the socket is connected.

Returns
True if the socket was successfully connected to the peer.

◆ getPeer()

bool ts::TCPConnection::getPeer ( IPv4SocketAddress addr,
Report report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))) 
) const
inherited

Get the connected remote peer.

Parameters
[out]addrIP address and port of the remote socket.
[in,out]reportWhere to report error.
Returns
True on success, false on error.

◆ peerName()

UString ts::TCPConnection::peerName ( ) const
inherited

Get the connected remote peer as a string.

Returns
A string representation of the IP address and port of the remote socket.

◆ closeWriter()

bool ts::TCPConnection::closeWriter ( Report report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))))
inherited

Close the write direction of the connection.

The application shall call this routine after sending the last message but may still want to receive messages, waiting for the peer to voluntary disconnect.

Parameters
[in,out]reportWhere to report error.
Returns
True on success, false on error.

◆ disconnect()

bool ts::TCPConnection::disconnect ( Report report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))))
inherited

Disconnect from remote partner.

Parameters
[in,out]reportWhere to report error.
Returns
True on success, false on error.

◆ send() [3/3]

bool ts::TCPConnection::send ( const void *  data,
size_t  size,
Report report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))) 
)
inherited

Send data.

Parameters
[in]dataAddress of the data to send.
[in]sizeSize in bytes of the data to send.
[in,out]reportWhere to report error.
Returns
True on success, false on error.

◆ receive() [3/4]

bool ts::TCPConnection::receive ( void *  buffer,
size_t  max_size,
size_t &  ret_size,
const AbortInterface abort = nullptr,
Report report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))) 
)
inherited

Receive data.

This version of receive() returns when "some" data are received into the user buffer. The actual received data may be shorter than the user buffer size.

The version is typically useful when the application cannot predict how much data will be received and must respond even if the user buffer is not full.

Parameters
[out]bufferAddress of the buffer for the received data.
[in]max_sizeSize in bytes of the reception buffer.
[out]ret_sizeSize in bytes of the received data. Will never be larger than max_size.
[in]abortIf non-zero, invoked when I/O is interrupted (in case of user-interrupt, return, otherwise retry).
[in,out]reportWhere to report error.
Returns
True on success, false on error.

◆ receive() [4/4]

bool ts::TCPConnection::receive ( void *  buffer,
size_t  size,
const AbortInterface abort = nullptr,
Report report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))) 
)
inherited

Receive data until buffer is full.

This version of receive() returns only when sufficient data are received to completely fill the user buffer. The size of the actual received data is identical to the user buffer size.

The version is typically useful when the application knows that a certain amount of data is expected and must wait for them.

Parameters
[out]bufferAddress of the buffer for the received data.
[in]sizeSize in bytes of the buffer.
[in]abortIf non-zero, invoked when I/O is interrupted (in case of user-interrupt, return, otherwise retry).
[in,out]reportWhere to report error.
Returns
True on success, false on error.

◆ handleConnected()

virtual void ts::TCPConnection::handleConnected ( Report report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))))
protectedvirtualinherited

This virtual method can be overriden by subclasses to be notified of connection.

All subclasses should explicitly invoke their superclass' handlers.

Parameters
[in,out]reportWhere to report error.

Reimplemented in ts::tlv::Connection< MUTEX >, and ts::tlv::Connection< ts::Mutex >.

◆ handleDisconnected()

virtual void ts::TCPConnection::handleDisconnected ( Report report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))))
protectedvirtualinherited

This virtual method can be overriden by subclasses to be notified of disconnection.

All subclasses should explicitly invoke their superclass' handlers.

Parameters
[in,out]reportWhere to report error.

◆ handleClosed()

virtual void ts::TCPConnection::handleClosed ( Report report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))))
overrideprotectedvirtualinherited

This virtual method can be overriden by subclasses to be notified of close.

All subclasses should explicitly invoke their superclass' handlers.

Parameters
[in,out]reportWhere to report error.

Reimplemented from ts::TCPSocket.

◆ setTTL()

bool ts::TCPSocket::setTTL ( int  ttl,
Report report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))) 
)
inherited

Set the Time To Live (TTL) option.

Parameters
[in]ttlThe TTL value, ie. the maximum number of "hops" between routers before an IP packet is dropped.
[in,out]reportWhere to report error.
Returns
True on success, false on error.

◆ setNoLinger()

bool ts::TCPSocket::setNoLinger ( Report report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))))
inherited

Remove the linger time option.

Parameters
[in,out]reportWhere to report error.
Returns
True on success, false on error.

◆ setLingerTime()

bool ts::TCPSocket::setLingerTime ( int  seconds,
Report report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))) 
)
inherited

Set the linger time option.

Parameters
[in]secondsNumber of seconds to wait after shuting down the socket.
[in,out]reportWhere to report error.
Returns
True on success, false on error.

◆ setKeepAlive()

bool ts::TCPSocket::setKeepAlive ( bool  active,
Report report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))) 
)
inherited

Set the "keep alive" option.

Parameters
[in]activeIf true, the socket periodically sends "keep alive" packets when the connection is idle.
[in,out]reportWhere to report error.
Returns
True on success, false on error.

◆ setNoDelay()

bool ts::TCPSocket::setNoDelay ( bool  active,
Report report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))) 
)
inherited

Set the "no delay" option.

Parameters
[in]activeIf true, the socket immediately sends outgoing packets. By default, a TCP socket waits a small amount of time after a send() operation to get a chance to group outgoing data from successive send() operations into one single packet.
[in,out]reportWhere to report error.
Returns
True on success, false on error.

◆ bind()

bool ts::TCPSocket::bind ( const IPv4SocketAddress addr,
Report report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))) 
)
inherited

Bind to a local address and port.

The IP address part of the socket address must one of:

  • IPv4Address::AnyAddress. Any local interface may be used to connect to a server (client side) or to receive incoming client connections (server side).
  • The IP address of an interface of the local system. Outgoing connections (client side) will be only allowed through this interface. Incoming client connections (server side) will be accepted only when they arrive through the selected interface.

The port number part of the socket address must be one of:

  • IPv4SocketAddress::AnyPort. The socket is bound to an arbitrary unused local TCP port. This is the usual configuration for a TCP client.
  • A specific port number. This is the usual configuration for a TCP server. If this TCP port is already bound by another local TCP socket, the bind operation fails, unless the "reuse port" option has already been set.
Parameters
[in]addrLocal socket address to bind to.
[in,out]reportWhere to report error.
Returns
True on success, false on error.

◆ open()

virtual bool ts::TCPSocket::open ( Report report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))))
overridevirtualinherited

Open the socket.

Parameters
[in,out]reportWhere to report error.
Returns
True on success, false on error.

Implements ts::Socket.

◆ close()

virtual bool ts::TCPSocket::close ( Report report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))))
overridevirtualinherited

Close the socket.

Parameters
[in,out]reportWhere to report error.
Returns
True on success, false on error.

Reimplemented from ts::Socket.

Reimplemented in ts::TCPServer.

◆ handleOpened()

virtual void ts::TCPSocket::handleOpened ( Report report)
protectedvirtualinherited

This virtual method can be overriden by subclasses to be notified of open.

All subclasses should explicitly invoke their superclass' handlers.

Parameters
[in,out]reportWhere to report error.

◆ declareOpened()

virtual void ts::TCPSocket::declareOpened ( SysSocketType  sock,
Report report 
)
overrideprotectedvirtualinherited

Set an open socket descriptor from a subclass.

This method is used by a server to declare that a client socket has just become opened.

Parameters
[in]sockNew socket descriptor.
[in,out]reportWhere to report error.

Reimplemented from ts::Socket.

◆ isOpen()

bool ts::Socket::isOpen ( ) const
inlineinherited

Check if socket is open.

Returns
True if socket is open.

◆ setSendBufferSize()

bool ts::Socket::setSendBufferSize ( size_t  size,
Report report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))) 
)
inherited

Set the send buffer size.

Parameters
[in]sizeSend buffer size in bytes.
[in,out]reportWhere to report error.
Returns
True on success, false on error.

◆ setReceiveBufferSize()

bool ts::Socket::setReceiveBufferSize ( size_t  size,
Report report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))) 
)
inherited

Set the receive buffer size.

Parameters
[in]sizeReceive buffer size in bytes.
[in,out]reportWhere to report error.
Returns
True on success, false on error.

◆ setReceiveTimeout()

bool ts::Socket::setReceiveTimeout ( MilliSecond  timeout,
Report report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))) 
)
inherited

Set the receive timeout.

Parameters
[in]timeoutReceive timeout in milliseconds. If negative, receive timeout is not used.
[in,out]reportWhere to report error.
Returns
True on success, false on error.

◆ reusePort()

bool ts::Socket::reusePort ( bool  reuse_port,
Report report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))) 
)
inherited

Set the "reuse port" option.

Parameters
[in]reuse_portIf true, the socket is allowed to reuse a local UDP port which is already bound.
[in,out]reportWhere to report error.
Returns
True on success, false on error.

◆ getLocalAddress()

bool ts::Socket::getLocalAddress ( IPv4SocketAddress addr,
Report report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))) 
)
inherited

Get local socket address.

Parameters
[out]addrLocal socket address of the connection.
[in,out]reportWhere to report error.
Returns
True on success, false on error.

◆ getSocket()

SysSocketType ts::Socket::getSocket ( ) const
inlineinherited

Get the underlying socket device handle (use with care).

This method is reserved for low-level operations and should not be used by normal applications.

Returns
The underlying socket system device handle or file descriptor. Return SYS_SOCKET_INVALID if the socket is not open.

◆ createSocket()

bool ts::Socket::createSocket ( int  domain,
int  type,
int  protocol,
Report report 
)
protectedinherited

Create the socket.

Parameters
[in]domainSocket domain: PF_INET
[in]typeSocket type: SOCK_STREAM, SOCK_DGRAM
[in]protocolSocket protocol: IPPROTO_TCP, IPPROTO_UDP
[in,out]reportWhere to report error.
Returns
True on success, false on error.

◆ setMaxSeverity()

virtual void ts::Report::setMaxSeverity ( int  level)
virtualinherited

Set maximum severity level.

Messages with higher severities are not reported.

Parameters
[in]levelSet report to that level.

Reimplemented in ts::ReportWithPrefix.

◆ raiseMaxSeverity()

virtual void ts::Report::raiseMaxSeverity ( int  level)
virtualinherited

Raise maximum severity level.

Parameters
[in]levelSet report at least to that level.

Reimplemented in ts::Args.

◆ maxSeverity()

int ts::Report::maxSeverity ( ) const
inlineinherited

Get maximum severity level.

Returns
Current maximum debug level.

◆ debug() [1/4]

bool ts::Report::debug ( ) const
inlineinherited

Check if debugging is active.

Returns
True if current reporting level is Debug or higher.

◆ debug() [2/4]

void ts::Report::debug ( const UString msg)
inlineinherited

Report a debug message.

Parameters
[in]msgMessage text.

◆ debug() [3/4]

void ts::Report::debug ( const UChar fmt,
std::initializer_list< ArgMixIn args 
)
inlineinherited

Report a debug message with a printf-like interface.

Parameters
[in]fmtFormat string with embedded '%' sequences.
[in]argsList of arguments to substitute in the format string.
See also
UString::format()

◆ debug() [4/4]

void ts::Report::debug ( const UString fmt,
std::initializer_list< ArgMixIn args 
)
inlineinherited

Report a debug message with a printf-like interface.

Parameters
[in]fmtFormat string with embedded '%' sequences.
[in]argsList of arguments to substitute in the format string.
See also
UString::format()

◆ verbose() [1/4]

bool ts::Report::verbose ( ) const
inlineinherited

Check if verbose reporting is active.

Returns
True if current reporting level is Verbose or higher.

◆ verbose() [2/4]

void ts::Report::verbose ( const UString msg)
inlineinherited

Report a verbose message.

Parameters
[in]msgMessage text.

◆ verbose() [3/4]

void ts::Report::verbose ( const UChar fmt,
std::initializer_list< ArgMixIn args 
)
inlineinherited

Report a verbose message with a printf-like interface.

Parameters
[in]fmtFormat string with embedded '%' sequences.
[in]argsList of arguments to substitute in the format string.
See also
UString::format()

◆ verbose() [4/4]

void ts::Report::verbose ( const UString fmt,
std::initializer_list< ArgMixIn args 
)
inlineinherited

Report a verbose message with a printf-like interface.

Parameters
[in]fmtFormat string with embedded '%' sequences.
[in]argsList of arguments to substitute in the format string.
See also
UString::format()

◆ log() [1/3]

virtual void ts::Report::log ( int  severity,
const UString msg 
)
virtualinherited

Report a message with an explicit severity.

This method is the central reporting point. If filters the severity and drops the message if severity is higher than maxSeverity().

Subclasses should override writeLog() to implement a specific reporting device. It is not necessary to override log() unless the subclass needs to implement a different severity filtering policy.

Parameters
[in]severityMessage severity.
[in]msgMessage text.

◆ log() [2/3]

virtual void ts::Report::log ( int  severity,
const UChar fmt,
std::initializer_list< ArgMixIn args 
)
virtualinherited

Report a message with an explicit severity and a printf-like interface.

Parameters
[in]severityMessage severity.
[in]fmtFormat string with embedded '%' sequences.
[in]argsList of arguments to substitute in the format string.
See also
UString::format()

◆ log() [3/3]

virtual void ts::Report::log ( int  severity,
const UString fmt,
std::initializer_list< ArgMixIn args 
)
virtualinherited

Report a message with an explicit severity and a printf-like interface.

Parameters
[in]severityMessage severity.
[in]fmtFormat string with embedded '%' sequences.
[in]argsList of arguments to substitute in the format string.
See also
UString::format()

◆ fatal() [1/3]

void ts::Report::fatal ( const UString msg)
inlineinherited

Report a fatal error message.

Parameters
[in]msgMessage text.

◆ fatal() [2/3]

void ts::Report::fatal ( const UChar fmt,
std::initializer_list< ArgMixIn args 
)
inlineinherited

Report a fatal error message with a printf-like interface.

Parameters
[in]fmtFormat string with embedded '%' sequences.
[in]argsList of arguments to substitute in the format string.
See also
UString::format()

◆ fatal() [3/3]

void ts::Report::fatal ( const UString fmt,
std::initializer_list< ArgMixIn args 
)
inlineinherited

Report a fatal error message with a printf-like interface.

Parameters
[in]fmtFormat string with embedded '%' sequences.
[in]argsList of arguments to substitute in the format string.
See also
UString::format()

◆ severe() [1/3]

void ts::Report::severe ( const UString msg)
inlineinherited

Report a severe error message.

Parameters
[in]msgMessage text.

◆ severe() [2/3]

void ts::Report::severe ( const UChar fmt,
std::initializer_list< ArgMixIn args 
)
inlineinherited

Report a severe error message with a printf-like interface.

Parameters
[in]fmtFormat string with embedded '%' sequences.
[in]argsList of arguments to substitute in the format string.
See also
UString::format()

◆ severe() [3/3]

void ts::Report::severe ( const UString fmt,
std::initializer_list< ArgMixIn args 
)
inlineinherited

Report a severe error message with a printf-like interface.

Parameters
[in]fmtFormat string with embedded '%' sequences.
[in]argsList of arguments to substitute in the format string.
See also
UString::format()

◆ error() [1/3]

void ts::Report::error ( const UString msg)
inlineinherited

Report an error message.

Parameters
[in]msgMessage text.

◆ error() [2/3]

void ts::Report::error ( const UChar fmt,
std::initializer_list< ArgMixIn args 
)
inlineinherited

Report an error message with a printf-like interface.

Parameters
[in]fmtFormat string with embedded '%' sequences.
[in]argsList of arguments to substitute in the format string.
See also
UString::format()

◆ error() [3/3]

void ts::Report::error ( const UString fmt,
std::initializer_list< ArgMixIn args 
)
inlineinherited

Report an error message with a printf-like interface.

Parameters
[in]fmtFormat string with embedded '%' sequences.
[in]argsList of arguments to substitute in the format string.
See also
UString::format()

◆ warning() [1/3]

void ts::Report::warning ( const UString msg)
inlineinherited

Report a warning message.

Parameters
[in]msgMessage text.

◆ warning() [2/3]

void ts::Report::warning ( const UChar fmt,
std::initializer_list< ArgMixIn args 
)
inlineinherited

Report a warning message with a printf-like interface.

Parameters
[in]fmtFormat string with embedded '%' sequences.
[in]argsList of arguments to substitute in the format string.
See also
UString::format()

◆ warning() [3/3]

void ts::Report::warning ( const UString fmt,
std::initializer_list< ArgMixIn args 
)
inlineinherited

Report a warning message with a printf-like interface.

Parameters
[in]fmtFormat string with embedded '%' sequences.
[in]argsList of arguments to substitute in the format string.
See also
UString::format()

◆ info() [1/3]

void ts::Report::info ( const UString msg)
inlineinherited

Report an informational message.

Parameters
[in]msgMessage text.

◆ info() [2/3]

void ts::Report::info ( const UChar fmt,
std::initializer_list< ArgMixIn args 
)
inlineinherited

Report an informational message with a printf-like interface.

Parameters
[in]fmtFormat string with embedded '%' sequences.
[in]argsList of arguments to substitute in the format string.
See also
UString::format()

◆ info() [3/3]

void ts::Report::info ( const UString fmt,
std::initializer_list< ArgMixIn args 
)
inlineinherited

Report an informational message with a printf-like interface.

Parameters
[in]fmtFormat string with embedded '%' sequences.
[in]argsList of arguments to substitute in the format string.
See also
UString::format()

◆ gotErrors()

bool ts::Report::gotErrors ( ) const
inlineinherited

Check if errors (or worse) were reported through this object.

Returns
True if errors (or worse) were reported through this object.

◆ resetErrors()

void ts::Report::resetErrors ( )
inlineinherited

Reset the error indicator.

See also
gotErrors()

The documentation for this class was generated from the following file: