#include <psockbun.h>
Inheritance diagram for PMonitoredSockets:
Public Member Functions | |
virtual BOOL | Open (WORD port)=0 |
BOOL | IsOpen () const |
Indicate if the socket(s) are open and ready for reads/writes. | |
virtual BOOL | Close ()=0 |
Close all socket(s). | |
WORD | GetPort () const |
Return the local port number being used by the socket(s). | |
virtual BOOL | GetAddress (const PString &iface, PIPSocket::Address &address, WORD &port, BOOL usingNAT) const=0 |
Get the local address for the given interface. | |
virtual PChannel::Errors | WriteToBundle (const void *buffer, PINDEX length, const PIPSocket::Address &addr, WORD port, const PString &iface, PINDEX &lastWriteCount)=0 |
virtual PChannel::Errors | ReadFromBundle (void *buffer, PINDEX length, PIPSocket::Address &addr, WORD &port, PString &iface, PINDEX &lastReadCount, const PTimeInterval &timeout)=0 |
void | SetSTUN (PSTUNClient *stunClient) |
Set the STUN server. | |
PSTUNClient * | GetSTUN () const |
Static Public Member Functions | |
static PMonitoredSockets * | Create (const PString &iface, BOOL reuseAddr=FALSE, PSTUNClient *stunClient=NULL) |
Protected Member Functions | |
PMonitoredSockets (BOOL reuseAddr, PSTUNClient *stunClient) | |
BOOL | CreateSocket (SocketInfo &info, const PIPSocket::Address &binding) |
BOOL | DestroySocket (SocketInfo &info) |
BOOL | GetSocketAddress (const SocketInfo &info, PIPSocket::Address &address, WORD &port, BOOL usingNAT) const |
PChannel::Errors | WriteToSocket (const void *buf, PINDEX len, const PIPSocket::Address &addr, WORD port, const SocketInfo &info, PINDEX &lastWriteCount) |
PChannel::Errors | ReadFromSocket (SocketInfo &info, void *buf, PINDEX len, PIPSocket::Address &addr, WORD &port, PINDEX &lastReadCount, const PTimeInterval &timeout) |
Protected Attributes | |
WORD | localPort |
BOOL | reuseAddress |
PSTUNClient * | stun |
bool | opened |
PUDPSocket | interfaceAddedSignal |
Classes | |
struct | SocketInfo |
PMonitoredSockets::PMonitoredSockets | ( | BOOL | reuseAddr, | |
PSTUNClient * | stunClient | |||
) | [protected] |
virtual BOOL PMonitoredSockets::Open | ( | WORD | port | ) | [pure virtual] |
Open the socket(s) using the specified port. If port is zero then a system allocated port is used. In this case and when multiple interfaces are supported, all sockets use the same dynamic port value.
Returns TRUE if all sockets are opened.
Implemented in PMonitoredSocketBundle, and PSingleMonitoredSocket.
BOOL PMonitoredSockets::IsOpen | ( | ) | const [inline] |
Indicate if the socket(s) are open and ready for reads/writes.
virtual BOOL PMonitoredSockets::Close | ( | ) | [pure virtual] |
WORD PMonitoredSockets::GetPort | ( | ) | const [inline] |
Return the local port number being used by the socket(s).
virtual BOOL PMonitoredSockets::GetAddress | ( | const PString & | iface, | |
PIPSocket::Address & | address, | |||
WORD & | port, | |||
BOOL | usingNAT | |||
) | const [pure virtual] |
Get the local address for the given interface.
address | Interface to get address for |
port | Address of interface |
usingNAT | Port listening on Require NAT address/port |
Implemented in PMonitoredSocketBundle, and PSingleMonitoredSocket.
virtual PChannel::Errors PMonitoredSockets::WriteToBundle | ( | const void * | buffer, | |
PINDEX | length, | |||
const PIPSocket::Address & | addr, | |||
WORD | port, | |||
const PString & | iface, | |||
PINDEX & | lastWriteCount | |||
) | [pure virtual] |
Write to the remote address/port using the socket(s) available. If the iface parameter is empty, then the data is written to all socket(s). Otherwise the iface parameter indicates the specific interface socket to write the data to.
length | Data to write |
addr | Length of data |
port | Remote IP address to write to |
iface | Remote port to write to |
lastWriteCount | Interface to use for writing |
Implemented in PMonitoredSocketBundle, and PSingleMonitoredSocket.
virtual PChannel::Errors PMonitoredSockets::ReadFromBundle | ( | void * | buffer, | |
PINDEX | length, | |||
PIPSocket::Address & | addr, | |||
WORD & | port, | |||
PString & | iface, | |||
PINDEX & | lastReadCount, | |||
const PTimeInterval & | timeout | |||
) | [pure virtual] |
Read fram a remote address/port using the socket(s) available. If the iface parameter is empty, then the first data received on any socket(s) is used, and the iface parameter is set to the name of that interface. Otherwise the iface parameter indicates the specific interface socket to read the data from.
length | Data to read |
addr | Maximum length of data |
port | Remote IP address data came from |
iface | Remote port data came from |
lastReadCount | Interface to use for read, also one data was read on |
timeout | Actual length of data read Time to wait for data |
Implemented in PMonitoredSocketBundle, and PSingleMonitoredSocket.
void PMonitoredSockets::SetSTUN | ( | PSTUNClient * | stunClient | ) | [inline] |
Set the STUN server.
PSTUNClient* PMonitoredSockets::GetSTUN | ( | ) | const [inline] |
static PMonitoredSockets* PMonitoredSockets::Create | ( | const PString & | iface, | |
BOOL | reuseAddr = FALSE , |
|||
PSTUNClient * | stunClient = NULL | |||
) | [static] |
Create a new monitored socket instance based on the interface descriptor. This will create a multiple or single socket derived class of PMonitoredSockets depending on teh iface parameter.
reuseAddr | Interface name to create socket for |
stunClient | Re-use or exclusive port number STUN client code |
BOOL PMonitoredSockets::CreateSocket | ( | SocketInfo & | info, | |
const PIPSocket::Address & | binding | |||
) | [protected] |
BOOL PMonitoredSockets::DestroySocket | ( | SocketInfo & | info | ) | [protected] |
BOOL PMonitoredSockets::GetSocketAddress | ( | const SocketInfo & | info, | |
PIPSocket::Address & | address, | |||
WORD & | port, | |||
BOOL | usingNAT | |||
) | const [protected] |
PChannel::Errors PMonitoredSockets::WriteToSocket | ( | const void * | buf, | |
PINDEX | len, | |||
const PIPSocket::Address & | addr, | |||
WORD | port, | |||
const SocketInfo & | info, | |||
PINDEX & | lastWriteCount | |||
) | [protected] |
PChannel::Errors PMonitoredSockets::ReadFromSocket | ( | SocketInfo & | info, | |
void * | buf, | |||
PINDEX | len, | |||
PIPSocket::Address & | addr, | |||
WORD & | port, | |||
PINDEX & | lastReadCount, | |||
const PTimeInterval & | timeout | |||
) | [protected] |
WORD PMonitoredSockets::localPort [protected] |
BOOL PMonitoredSockets::reuseAddress [protected] |
PSTUNClient* PMonitoredSockets::stun [protected] |
bool PMonitoredSockets::opened [protected] |
PUDPSocket PMonitoredSockets::interfaceAddedSignal [protected] |