PTLib Version 2.12.9

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PSingleMonitoredSocket Class Reference

This concrete class monitors a single scoket bound to a specific interface or address. More...

`#include <psockbun.h>`

Inheritance diagram for PSingleMonitoredSocket:
[legend]
Collaboration diagram for PSingleMonitoredSocket:
[legend]

## Public Member Functions
| PSingleMonitoredSocket (const PString &theInterface, bool reuseAddrP_NAT_PARAM(PNatMethod *natMethod=NULL))
| ~PSingleMonitoredSocket ()
virtual PStringArray | GetInterfaces (bool includeLoopBack=false, const PIPSocket::Address &destination=PIPSocket::GetDefaultIpAny())
| Get an array of all current interface descriptors, possibly including the loopback (127.0.0.1) interface. More...
virtual PBoolean | Open (WORD port)
| Open the socket(s) using the specified port. More...
virtual PBoolean | Close ()
| Close all socket(s) More...
virtual PBoolean | GetAddress (const PString &iface, PIPSocket::Address &address, WORD &port, PBoolean usingNAT) const
| Get the local address for the given interface. More...
virtual void | WriteToBundle (BundleParams &param)
| Write to the remote address/port using the socket(s) available. More...
virtual void | ReadFromBundle (BundleParams &param)
| Read fram a remote address/port using the socket(s) available. More...
Public Member Functions inherited from PMonitoredSockets
PBoolean | IsOpen () const
| Indicate if the socket(s) are open and ready for reads/writes. More...
WORD | GetPort () const
| Return the local port number being used by the socket(s) More...
virtual bool | GetInterfaceInfo (const PString &iface, InterfaceEntry &info) const
| Return information about an active interface given the descriptor string. More...
Public Member Functions inherited from PSafeObject
| PSafeObject (PSafeObject *indirectLock=NULL)
| Create a thread safe object. More...
PBoolean | SafeReference ()
| Increment the reference count for object. More...
PBoolean | SafeDereference ()
| Decrement the reference count for object. More...
PBoolean | LockReadOnly () const
| Lock the object for Read Only access. More...
void | UnlockReadOnly () const
| Release the read only lock on an object. More...
PBoolean | LockReadWrite ()
| Lock the object for Read/Write access. More...
void | UnlockReadWrite ()
| Release the read/write lock on an object. More...
void | SafeRemove ()
| Set the removed flag. More...
PBoolean | SafelyCanBeDeleted () const
| Determine if the object can be safely deleted. More...
virtual bool | GarbageCollection ()
| Do any garbage collection that may be required by the object so that it may be finally deleted. More...
unsigned | GetSafeReferenceCount () const
| Get count of references to this object. More...
Public Member Functions inherited from PObject
unsigned | GetTraceContextIdentifier () const
| Get PTRACE context identifier. More...
void | SetTraceContextIdentifier (unsigned id)
void | GetTraceContextIdentifier (PObject &obj)
void | GetTraceContextIdentifier (PObject *obj)
void | SetTraceContextIdentifier (const PObject &obj)
void | SetTraceContextIdentifier (const PObject *obj)
virtual | ~PObject ()
virtual PObject * | Clone () const
| Create a copy of the class on the heap. More...
template<class CLS >
CLS * | CloneAs () const
| As for Clone() but converts to specified type. More...
virtual PINDEX | HashFunction () const
| This function yields a hash value required by the `PDictionary` class. More...
virtual const char * | GetClass (unsigned ancestor=0) const
| Get the current dynamic type of the object instance. More...
PBoolean | IsClass (const char *cls) const
virtual PBoolean | InternalIsDescendant (const char *clsName) const
| Determine if the dynamic type of the current instance is a descendent of the specified class. More...
__inline const PObject * | PTraceObjectInstance () const
virtual Comparison | Compare (const PObject &obj) const
| Compare the two objects and return their relative rank. More...
virtual Comparison | CompareObjectMemoryDirect (const PObject &obj) const
| Determine the byte wise comparison of two objects. More...
bool | operator== (const PObject &obj) const
| Compare the two objects. More...
bool | operator!= (const PObject &obj) const
| Compare the two objects. More...
bool | operator< (const PObject &obj) const
| Compare the two objects. More...
bool | operator> (const PObject &obj) const
| Compare the two objects. More...
bool | operator<= (const PObject &obj) const
| Compare the two objects. More...
bool | operator>= (const PObject &obj) const
| Compare the two objects. More...
virtual void | PrintOn (ostream &strm) const
| Output the contents of the object to the stream. More...
virtual void | ReadFrom (istream &strm)
| Input the contents of the object from the stream. More...

## Protected Member Functions
| PDECLARE_InterfaceNotifier (PSingleMonitoredSocket, OnInterfaceChange)
bool | IsInterface (const PString &iface) const
Protected Member Functions inherited from PMonitoredSockets
| PMonitoredSockets (bool reuseAddrP_NAT_PARAM(PNatMethod *natMethod))
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
void | ReadFromSocketList (PSocket::SelectList &readers, PUDPSocket *&socket, BundleParams &param)

## Protected Attributes
PInterfaceMonitor::Notifier | m_onInterfaceChange
PString | m_interface
InterfaceEntry | m_entry
SocketInfo | m_info
Protected Attributes inherited from PMonitoredSockets
WORD | localPort
bool | reuseAddress
bool | opened
PUDPSocket | interfaceAddedSignal

## Additional Inherited Members
Public Types inherited from PMonitoredSockets
typedef PIPSocket::InterfaceEntry | InterfaceEntry
Static Public Member Functions inherited from PMonitoredSockets
static PMonitoredSockets * | Create (const PString &iface, bool reuseAddr=falseP_NAT_PARAM(PNatMethod *natMethod=NULL))
| Create a new monitored socket instance based on the interface descriptor. More...
Friends inherited from PObject

## Detailed Description

This concrete class monitors a single scoket bound to a specific interface or address.

The interface name may be a partial descriptor such as "%eth0".

## Constructor & Destructor Documentation

PSingleMonitoredSocket::PSingleMonitoredSocket | ( | const PString & | theInterface,
|  | bool | reuseAddrP_NAT_PARAMPNatMethod *natMethod=NULL
| ) |  |

Parameters

  theInterface | Interface to bind to
  reuseAddrP_NAT_PARAM | Flag for sharing socket/exclusve use NET method to use to create sockets.

PSingleMonitoredSocket::~PSingleMonitoredSocket | ( |  | ) |

## Member Function Documentation

virtual PBoolean PSingleMonitoredSocket::Close | ( |  | ) |
| virtual

Close all socket(s)

Implements PMonitoredSockets.

virtual PBoolean PSingleMonitoredSocket::GetAddress | ( | const PString & | iface,
|  | PIPSocket::Address & | address,
|  | WORD & | port,
|  | PBoolean | usingNAT
| ) |  | const
| virtual

Get the local address for the given interface.

Parameters

  iface | Interface to get address for
  address | Address of interface
  port | Port listening on
  usingNAT | Require NAT address/port

Implements PMonitoredSockets.

virtual PStringArray PSingleMonitoredSocket::GetInterfaces | ( | bool | includeLoopBack = `false`,
|  | const PIPSocket::Address & | destination = `PIPSocket::GetDefaultIpAny()`
| ) |  |
| virtual

Get an array of all current interface descriptors, possibly including the loopback (127.0.0.1) interface.

Note the names are of the form ipname, eg "10.0.1.11%3Com 3C90x Ethernet Adapter" or "192.168.0.10%eth0"

Parameters

  includeLoopBack | Flag for if loopback is to included in list
  destination | Optional destination for selecting specific interface

Reimplemented from PMonitoredSockets.

bool PSingleMonitoredSocket::IsInterface | ( | const PString & | iface | ) | const
| protected

virtual PBoolean PSingleMonitoredSocket::Open | ( | WORD | port | ) |
| 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.

Implements PMonitoredSockets.

PSingleMonitoredSocket::PDECLARE_InterfaceNotifier | ( | PSingleMonitoredSocket | ,
|  | OnInterfaceChange |
| ) |  |
| protected

virtual void PSingleMonitoredSocket::ReadFromBundle | ( | BundleParams & | param | ) |
| 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.

Parameters

  param | Info on data to read

Implements PMonitoredSockets.

virtual void PSingleMonitoredSocket::WriteToBundle | ( | BundleParams & | param | ) |
| 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.

Parameters

  param | Info on data to write

Implements PMonitoredSockets.

## Member Data Documentation

InterfaceEntry PSingleMonitoredSocket::m_entry
| protected

SocketInfo PSingleMonitoredSocket::m_info
| protected

PString PSingleMonitoredSocket::m_interface
| protected

PInterfaceMonitor::Notifier PSingleMonitoredSocket::m_onInterfaceChange
| protected

The documentation for this class was generated from the following file:

- psockbun.h