PTLib  Version 2.10.4
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

Construct a monitored socket bundle channel.

Parameters:
socketsMonitored socket bundle to use in channel
sharedMonitored socket is shared by other channels

Member Function Documentation

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

Returns:
true if the channel successfully closed.

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.

Parameters:
addrRemote IP address
portRemote port number

References lastReceivedAddress, and lastReceivedPort.

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.

Parameters:
addressIP address of local interface
portPort listening on
usingNATRequire NAT address/port

Get the monitored socket bundle being used by this channel.

References socketBundle.

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.

Parameters:
addrRemote IP address
portRemote port number

References remoteAddress, and remotePort.

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.

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:
ifaceInterface 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:
flagNew flag

References promiscuousReads.

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

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

Parameters:
addressRemote IP address
portRemote port number
void PMonitoredSocketChannel::SetRemote ( const PString hostAndPort)

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

Parameters:
hostAndPortString of the form host[:port]
virtual PBoolean PMonitoredSocketChannel::Write ( const void *  buffer,
PINDEX  length 
) [virtual]

Override of PChannel functions to allow connectionless writes.

Reimplemented from PChannel.


Member Data Documentation

Referenced by GetRemote().


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines