PMonitoredSocketChannel Class Reference

#include <psockbun.h>

Inheritance diagram for PMonitoredSocketChannel:

PChannel PObject List of all members.

Public Member Functions

Overrides from class PSocket
virtual PBoolean IsOpen () const
virtual PBoolean Close ()
virtual PBoolean Read (void *buffer, PINDEX length)
virtual PBoolean Write (const void *buffer, PINDEX length)
New functions for class
void SetInterface (const PString &iface)
const PStringGetInterface ()
 Get the current interface descriptor being used/.
bool GetLocal (PIPSocket::Address &address, WORD &port, bool usingNAT)
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)
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

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:
shared  Monitored socket bundle to use in channel Monitored socket is shared by other channels

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

Construct a monitored socket bundle channel.

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


Member Function Documentation

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:
PTrue if the channel is open.

Reimplemented from PChannel.

virtual PBoolean PMonitoredSocketChannel::Close (  )  [virtual]

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

Returns:
PTrue if the channel successfully closed.

Reimplemented from PChannel.

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

Override of PChannel functions to allow connectionless reads

Reimplemented from PChannel.

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

Low level write to the channel. This function will block until the requested number of characters are written or the write timeout is reached. The GetLastWriteCount() function returns the actual number of bytes written.

The GetErrorCode() function should be consulted after Write() returns PFalse to determine what caused the failure.

Returns:
PTrue if at least len bytes were written to the channel.
Parameters:
buffer  Override of PChannel functions to allow connectionless writes

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

const PString& PMonitoredSocketChannel::GetInterface (  ) 

Get the current interface descriptor being used/.

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

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

Parameters:
port  IP address of local interface
usingNAT  Port listening on Require NAT address/port

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

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

Parameters:
port  Remote IP address Remote port number

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::GetRemote ( PIPSocket::Address addr,
WORD &  port 
) const [inline]

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

Parameters:
port  Remote IP address Remote port number

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

bool PMonitoredSocketChannel::GetPromiscuous (  )  [inline]

Get flag for receiving UDP data from any remote address.

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

Get the IP address and port of the last received UDP data.

Parameters:
port  Remote IP address Remote port number

PString PMonitoredSocketChannel::GetLastReceivedInterface (  )  const [inline]

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

const PMonitoredSocketsPtr& PMonitoredSocketChannel::GetMonitoredSockets (  )  const [inline]

Get the monitored socket bundle being used by this channel.


Member Data Documentation

PMonitoredSocketsPtr PMonitoredSocketChannel::socketBundle [protected]

bool PMonitoredSocketChannel::sharedBundle [protected]

PString PMonitoredSocketChannel::currentInterface [protected]

bool PMonitoredSocketChannel::promiscuousReads [protected]

PIPSocket::Address PMonitoredSocketChannel::remoteAddress [protected]

bool PMonitoredSocketChannel::closing [protected]

WORD PMonitoredSocketChannel::remotePort [protected]

PIPSocket::Address PMonitoredSocketChannel::lastReceivedAddress [protected]

WORD PMonitoredSocketChannel::lastReceivedPort [protected]

PString PMonitoredSocketChannel::lastReceivedInterface [protected]


The documentation for this class was generated from the following file:
Generated on Mon Sep 15 01:21:37 2008 for PTLib by  doxygen 1.5.1