PMonitoredSocketChannel Class Reference

This class can be used to access the bundled/monitored UDP sockets using the PChannel API. More...

#include <psockbun.h>

Inheritance diagram for PMonitoredSocketChannel:

PChannel PObject List of all members.

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 PMonitoredSocketsPtrGetMonitoredSockets () 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

Detailed Description

This class can be used to access the bundled/monitored UDP sockets using the PChannel API.


Constructor & Destructor Documentation

PMonitoredSocketChannel::PMonitoredSocketChannel ( const PMonitoredSocketsPtr sockets,
bool  shared 
)

Construct a monitored socket bundle channel.

Parameters:
sockets  Monitored socket bundle to use in channel
shared  Monitored socket is shared by other channels


Member Function Documentation

virtual PBoolean PMonitoredSocketChannel::Close (  )  [virtual]

Close the channel, shutting down the link to the data source.

Returns:
true if the channel successfully closed.

Reimplemented from PChannel.

PString PMonitoredSocketChannel::GetInterface (  ) 

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.

Parameters:
addr  Remote IP address
port  Remote port number

PString PMonitoredSocketChannel::GetLastReceivedInterface (  )  const [inline]

Get the interface the last received UDP data was recieved on.

bool PMonitoredSocketChannel::GetLocal ( PIPSocket::Address address,
WORD &  port,
bool  usingNAT 
)

Get the local IP address and port for the currently selected interface.

Parameters:
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.

bool PMonitoredSocketChannel::GetPromiscuous (  )  [inline]

Get flag for receiving UDP data from any remote address.

void PMonitoredSocketChannel::GetRemote ( PIPSocket::Address addr,
WORD &  port 
) const [inline]

Get the current remote address/port for all Write() functions.

Parameters:
addr  Remote IP address
port  Remote port number

virtual PBoolean PMonitoredSocketChannel::IsOpen (  )  const [virtual]

Determine if the channel is currently open.

This indicates that read and write operations can be executed on the channel. For example, in the PFile class it returns if the file is currently open.

Returns:
true if the channel is open.

Reimplemented from PChannel.

virtual PBoolean PMonitoredSocketChannel::Read ( void *  buffer,
PINDEX  length 
) [virtual]

Override of PChannel functions to allow connectionless reads.

Reimplemented from PChannel.

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".

Parameters:
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.

Parameters:
flag  New flag

void PMonitoredSocketChannel::SetRemote ( const PString hostAndPort  ) 

Set the remote address/port for all Write() functions.

Parameters:
hostAndPort  String of the form host[:port]

void PMonitoredSocketChannel::SetRemote ( const PIPSocket::Address address,
WORD  port 
)

Set the remote address/port for all Write() functions.

Parameters:
address  Remote IP address
port  Remote port number

virtual PBoolean PMonitoredSocketChannel::Write ( const void *  buffer,
PINDEX  length 
) [virtual]

Override of PChannel functions to allow connectionless writes.

Reimplemented from PChannel.


Member Data Documentation

bool PMonitoredSocketChannel::closing [protected]

PString PMonitoredSocketChannel::currentInterface [protected]

PIPSocket::Address PMonitoredSocketChannel::lastReceivedAddress [protected]

PString PMonitoredSocketChannel::lastReceivedInterface [protected]

WORD PMonitoredSocketChannel::lastReceivedPort [protected]

PMutex PMonitoredSocketChannel::mutex [protected]

bool PMonitoredSocketChannel::promiscuousReads [protected]

PIPSocket::Address PMonitoredSocketChannel::remoteAddress [protected]

WORD PMonitoredSocketChannel::remotePort [protected]

bool PMonitoredSocketChannel::sharedBundle [protected]

PMonitoredSocketsPtr PMonitoredSocketChannel::socketBundle [protected]


The documentation for this class was generated from the following file:
Generated on Fri Oct 14 01:44:12 2011 for PTLib by  doxygen 1.4.7