PTLib
Version 2.10.4
|
This class can be used to access the bundled/monitored UDP sockets using the PChannel API. More...
#include <psockbun.h>
Public Member Functions | |
Construction | |
PMonitoredSocketChannel (const PMonitoredSocketsPtr &sockets, bool shared) | |
Construct a monitored socket bundle channel. | |
Overrides from class PSocket | |
virtual PBoolean | IsOpen () const |
Determine if the channel is currently open. | |
virtual PBoolean | Close () |
Close the channel, shutting down the link to the data source. | |
virtual PBoolean | Read (void *buffer, PINDEX length) |
Override of PChannel functions to allow connectionless reads. | |
virtual PBoolean | Write (const void *buffer, PINDEX length) |
Override of PChannel functions to allow connectionless writes. | |
New functions for class | |
void | SetInterface (const PString &iface) |
Set the interface descriptor to be used for all reads/writes to this channel. | |
PString | GetInterface () |
Get the current interface descriptor being used/. | |
bool | GetLocal (PIPSocket::Address &address, WORD &port, bool usingNAT) |
Get the local IP address and port for the currently selected interface. | |
void | SetRemote (const PIPSocket::Address &address, WORD port) |
Set the remote address/port for all Write() functions. | |
void | SetRemote (const PString &hostAndPort) |
Set the remote address/port for all Write() functions. | |
void | GetRemote (PIPSocket::Address &addr, WORD &port) const |
Get the current remote address/port for all Write() functions. | |
void | SetPromiscuous (bool flag) |
Set flag for receiving UDP data from any remote address. | |
bool | GetPromiscuous () |
Get flag for receiving UDP data from any remote address. | |
void | GetLastReceived (PIPSocket::Address &addr, WORD &port) const |
Get the IP address and port of the last received UDP data. | |
PString | GetLastReceivedInterface () const |
Get the interface the last received UDP data was recieved on. | |
const PMonitoredSocketsPtr & | GetMonitoredSockets () const |
Get the monitored socket bundle being used by this channel. | |
Protected Attributes | |
PMonitoredSocketsPtr | socketBundle |
bool | sharedBundle |
PString | currentInterface |
bool | promiscuousReads |
PIPSocket::Address | remoteAddress |
bool | closing |
WORD | remotePort |
PIPSocket::Address | lastReceivedAddress |
WORD | lastReceivedPort |
PString | lastReceivedInterface |
PMutex | mutex |
This class can be used to access the bundled/monitored UDP sockets using the PChannel API.
PMonitoredSocketChannel::PMonitoredSocketChannel | ( | const PMonitoredSocketsPtr & | sockets, |
bool | shared | ||
) |
Construct a monitored socket bundle channel.
sockets | Monitored socket bundle to use in channel |
shared | Monitored socket is shared by other channels |
virtual PBoolean PMonitoredSocketChannel::Close | ( | ) | [virtual] |
Close the channel, shutting down the link to the data source.
Reimplemented from PChannel.
Get the current interface descriptor being used/.
void PMonitoredSocketChannel::GetLastReceived | ( | PIPSocket::Address & | addr, |
WORD & | port | ||
) | const [inline] |
Get the IP address and port of the last received UDP data.
addr | Remote IP address |
port | Remote port number |
References lastReceivedAddress, and lastReceivedPort.
PString PMonitoredSocketChannel::GetLastReceivedInterface | ( | ) | const [inline] |
Get the interface the last received UDP data was recieved on.
References lastReceivedInterface.
bool PMonitoredSocketChannel::GetLocal | ( | PIPSocket::Address & | address, |
WORD & | port, | ||
bool | usingNAT | ||
) |
Get the local IP address and port for the currently selected interface.
address | IP address of local interface |
port | Port listening on |
usingNAT | Require NAT address/port |
const PMonitoredSocketsPtr& PMonitoredSocketChannel::GetMonitoredSockets | ( | ) | const [inline] |
Get the monitored socket bundle being used by this channel.
References socketBundle.
bool PMonitoredSocketChannel::GetPromiscuous | ( | ) | [inline] |
Get flag for receiving UDP data from any remote address.
References promiscuousReads.
void PMonitoredSocketChannel::GetRemote | ( | PIPSocket::Address & | addr, |
WORD & | port | ||
) | const [inline] |
Get the current remote address/port for all Write() functions.
addr | Remote IP address |
port | Remote port number |
References remoteAddress, and remotePort.
virtual PBoolean PMonitoredSocketChannel::IsOpen | ( | ) | const [virtual] |
virtual PBoolean PMonitoredSocketChannel::Read | ( | void * | buffer, |
PINDEX | length | ||
) | [virtual] |
void PMonitoredSocketChannel::SetInterface | ( | const PString & | iface | ) |
Set the interface descriptor to be used for all reads/writes to this channel.
The iface parameter can be a partial descriptor eg "%eth0".
iface | Interface descriptor |
void PMonitoredSocketChannel::SetPromiscuous | ( | bool | flag | ) | [inline] |
Set flag for receiving UDP data from any remote address.
If the flag is false then data received from anything other than the configured remote address and port is ignored.
flag | New flag |
References promiscuousReads.
void PMonitoredSocketChannel::SetRemote | ( | const PIPSocket::Address & | address, |
WORD | port | ||
) |
Set the remote address/port for all Write() functions.
address | Remote IP address |
port | Remote port number |
void PMonitoredSocketChannel::SetRemote | ( | const PString & | hostAndPort | ) |
Set the remote address/port for all Write() functions.
hostAndPort | String of the form host[:port] |
virtual PBoolean PMonitoredSocketChannel::Write | ( | const void * | buffer, |
PINDEX | length | ||
) | [virtual] |
bool PMonitoredSocketChannel::closing [protected] |
PString PMonitoredSocketChannel::currentInterface [protected] |
Referenced by GetLastReceived().
Referenced by GetLastReceivedInterface().
WORD PMonitoredSocketChannel::lastReceivedPort [protected] |
Referenced by GetLastReceived().
PMutex PMonitoredSocketChannel::mutex [protected] |
bool PMonitoredSocketChannel::promiscuousReads [protected] |
Referenced by GetPromiscuous(), and SetPromiscuous().
Referenced by GetRemote().
WORD PMonitoredSocketChannel::remotePort [protected] |
Referenced by GetRemote().
bool PMonitoredSocketChannel::sharedBundle [protected] |
Referenced by GetMonitoredSockets().