#include <psockbun.h>
Inheritance diagram for PMonitoredSockets:
Public Member Functions | |
virtual PBoolean | Open (WORD port)=0 |
PBoolean | IsOpen () const |
Indicate if the socket(s) are open and ready for reads/writes. | |
virtual PBoolean | Close ()=0 |
Close all socket(s). | |
WORD | GetPort () const |
Return the local port number being used by the socket(s). | |
virtual PBoolean | GetAddress (const PString &iface, PIPSocket::Address &address, WORD &port, PBoolean 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 | SetNatMethod (PNatMethod *method) |
Set the NAT method, eg STUN client pointer. | |
PNatMethod * | GetNatMethod () const |
Static Public Member Functions | |
static PMonitoredSockets * | Create (const PString &iface, bool reuseAddr=false, PNatMethod *natMethod=NULL) |
Protected Member Functions | |
PMonitoredSockets (bool reuseAddr, PNatMethod *natMethod) | |
virtual void | OnRemoveNatMethod (const PNatMethod *natMethod) |
Called when a NAT method is about to be destroyed. | |
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) |
PChannel::Errors | ReadFromSocket (PSocket::SelectList &readers, PUDPSocket *&socket, void *buf, PINDEX len, PIPSocket::Address &addr, WORD &port, PINDEX &lastReadCount, const PTimeInterval &timeout) |
Protected Attributes | |
WORD | localPort |
bool | reuseAddress |
PNatMethod * | natMethod |
bool | opened |
PUDPSocket | interfaceAddedSignal |
Classes | |
struct | SocketInfo |
PMonitoredSockets::PMonitoredSockets | ( | bool | reuseAddr, | |
PNatMethod * | natMethod | |||
) | [protected] |
virtual PBoolean 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.
PBoolean PMonitoredSockets::IsOpen | ( | ) | const [inline] |
Indicate if the socket(s) are open and ready for reads/writes.
virtual PBoolean PMonitoredSockets::Close | ( | ) | [pure virtual] |
WORD PMonitoredSockets::GetPort | ( | ) | const [inline] |
Return the local port number being used by the socket(s).
virtual PBoolean PMonitoredSockets::GetAddress | ( | const PString & | iface, | |
PIPSocket::Address & | address, | |||
WORD & | port, | |||
PBoolean | 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::SetNatMethod | ( | PNatMethod * | method | ) | [inline] |
Set the NAT method, eg STUN client pointer.
PNatMethod* PMonitoredSockets::GetNatMethod | ( | ) | const [inline] |
static PMonitoredSockets* PMonitoredSockets::Create | ( | const PString & | iface, | |
bool | reuseAddr = false , |
|||
PNatMethod * | natMethod = 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 |
natMethod | Re-use or exclusive port number NAT method |
virtual void PMonitoredSockets::OnRemoveNatMethod | ( | const PNatMethod * | natMethod | ) | [protected, virtual] |
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] |
PChannel::Errors PMonitoredSockets::ReadFromSocket | ( | PSocket::SelectList & | readers, | |
PUDPSocket *& | socket, | |||
void * | buf, | |||
PINDEX | len, | |||
PIPSocket::Address & | addr, | |||
WORD & | port, | |||
PINDEX & | lastReadCount, | |||
const PTimeInterval & | timeout | |||
) | [protected] |
WORD PMonitoredSockets::localPort [protected] |
bool PMonitoredSockets::reuseAddress [protected] |
PNatMethod* PMonitoredSockets::natMethod [protected] |
bool PMonitoredSockets::opened [protected] |
PUDPSocket PMonitoredSockets::interfaceAddedSignal [protected] |