TSDuck v3.40-4033
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. | |
IP | generation () const |
Get the IP generation with which the socket was open. | |
bool | getLocalAddress (IPSocketAddress &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 (IP gen, 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 | convert (IPAddress &addr, Report &report) const |
Convert an IP address to make it compatible with the socket IP generation. | |
bool | createSocket (IP gen, 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] | gen | IP generation, IPv4 or IPv6. If set to IP::Any, open an IPv6 socket (IPv4 connections allowed). |
[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.
|
inline |
Get the IP generation with which the socket was 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 | ( | IPSocketAddress & | 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.
|
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.
Convert an IP address to make it compatible with the socket IP generation.
addr | [in,out] The address to convert. | |
[in,out] | report | Where to report error. |