TSDuck v3.40-3963
MPEG Transport Stream Toolkit
|
Base class for TCP and UDP sockets. More...
#include <tsSocket.h>
Public Member Functions | |
Socket ()=default | |
Constructor. | |
virtual | ~Socket () |
Destructor. | |
virtual bool | close (Report &report=(ts::CerrReport::Instance())) |
Close the socket. | |
bool | getLocalAddress (IPv4SocketAddress &addr, Report &report=(ts::CerrReport::Instance())) |
Get local socket address. | |
SysSocketType | getSocket () const |
Get the underlying socket device handle (use with care). | |
bool | isOpen () const |
Check if socket is open. | |
virtual bool | open (Report &report=(ts::CerrReport::Instance()))=0 |
Open the socket. | |
bool | reusePort (bool reuse_port, Report &report=(ts::CerrReport::Instance())) |
Set the "reuse port" option. | |
bool | setReceiveBufferSize (size_t size, Report &report=(ts::CerrReport::Instance())) |
Set the receive buffer size. | |
bool | setReceiveTimeout (cn::milliseconds timeout, Report &report=(ts::CerrReport::Instance())) |
Set the receive timeout. | |
bool | setSendBufferSize (size_t size, Report &report=(ts::CerrReport::Instance())) |
Set the send buffer size. | |
Protected Member Functions | |
bool | createSocket (int domain, int type, int protocol, Report &report) |
Create the socket. | |
virtual void | declareOpened (SysSocketType sock, Report &report) |
Set an open socket descriptor from a subclass. | |
Base class for TCP and UDP sockets.
|
pure virtual |
Open the socket.
[in,out] | report | Where to report error. |
Implemented in ts::TCPSocket, ts::UDPReceiver, and ts::UDPSocket.
|
virtual |
Close the socket.
[in,out] | report | Where to report error. |
Reimplemented in ts::TCPServer, ts::TCPSocket, and ts::UDPSocket.
|
inline |
Check if socket is open.
bool ts::Socket::setSendBufferSize | ( | size_t | size, |
Report & | report = (ts::CerrReport::Instance()) |
||
) |
Set the send buffer size.
[in] | size | Send buffer size in bytes. |
[in,out] | report | Where to report error. |
bool ts::Socket::setReceiveBufferSize | ( | size_t | size, |
Report & | report = (ts::CerrReport::Instance()) |
||
) |
Set the receive buffer size.
[in] | size | Receive buffer size in bytes. |
[in,out] | report | Where to report error. |
bool ts::Socket::setReceiveTimeout | ( | cn::milliseconds | timeout, |
Report & | report = (ts::CerrReport::Instance()) |
||
) |
Set the receive timeout.
[in] | timeout | Receive timeout in milliseconds. If negative, receive timeout is not used. |
[in,out] | report | Where to report error. |
bool ts::Socket::reusePort | ( | bool | reuse_port, |
Report & | report = (ts::CerrReport::Instance()) |
||
) |
Set the "reuse port" option.
[in] | reuse_port | If true, the socket is allowed to reuse a local UDP port which is already bound. |
[in,out] | report | Where to report error. |
bool ts::Socket::getLocalAddress | ( | IPv4SocketAddress & | addr, |
Report & | report = (ts::CerrReport::Instance()) |
||
) |
Get local socket address.
[out] | addr | Local socket address of the connection. |
[in,out] | report | Where to report error. |
|
inline |
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.
|
protected |
|
protectedvirtual |
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.
[in] | sock | New socket descriptor. |
[in,out] | report | Where to report error. |
Reimplemented in ts::TCPSocket.