PTLib  Version 2.14.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PIPSocket::PortRange Class Reference

Class for handling a range of ports for local binding. More...

#include <ipsock.h>

Collaboration diagram for PIPSocket::PortRange:

Public Member Functions

 PortRange (WORD basePort=0, WORD maxPort=0)
 
void Set (unsigned newBase, unsigned newMax, unsigned dfltRange=0, unsigned dfltBase=0)
 Set the port range parameters. More...
 
bool IsValid () const
 
bool Connect (PIPSocket &socket, const Address &addr, const Address &binding=GetDefaultIpAny())
 Connect to remote. More...
 
bool Listen (PIPSocket &socket, const Address &binding=GetDefaultIpAny(), unsigned queueSize=5, Reusability reuse=AddressIsExclusive)
 Listen on the socket(s) with local port in the range. More...
 
bool Listen (PIPSocket **sockets, PINDEX numSockets=1, const Address &binding=GetDefaultIpAny(), unsigned queueSize=5, Reusability reuse=AddressIsExclusive)
 
WORD GetBase () const
 Get base port for range. More...
 
WORD GetMax () const
 Get maximum port for range. More...
 

Protected Attributes

PMutex m_mutex
 
WORD m_base
 
WORD m_max
 

Friends

ostream & operator<< (ostream &strm, const PortRange &pr)
 

Detailed Description

Class for handling a range of ports for local binding.

Constructor & Destructor Documentation

PIPSocket::PortRange::PortRange ( WORD  basePort = 0,
WORD  maxPort = 0 
)

Member Function Documentation

bool PIPSocket::PortRange::Connect ( PIPSocket socket,
const Address addr,
const Address binding = GetDefaultIpAny() 
)

Connect to remote.

Parameters
socketSocket to connect on
addrAddress of remote machine to connect to.
bindingLocal interface address to bind to.
WORD PIPSocket::PortRange::GetBase ( ) const
inline

Get base port for range.

References m_base.

WORD PIPSocket::PortRange::GetMax ( ) const
inline

Get maximum port for range.

References m_max.

bool PIPSocket::PortRange::IsValid ( ) const
inline

References m_base, and m_max.

bool PIPSocket::PortRange::Listen ( PIPSocket socket,
const Address binding = GetDefaultIpAny(),
unsigned  queueSize = 5,
Reusability  reuse = AddressIsExclusive 
)

Listen on the socket(s) with local port in the range.

Parameters
socketSocket to listen on
bindingLocal interface address to bind to.
queueSizeNumber of pending accepts that may be queued.
reuseCan/Can't listen more than once.
bool PIPSocket::PortRange::Listen ( PIPSocket **  sockets,
PINDEX  numSockets = 1,
const Address binding = GetDefaultIpAny(),
unsigned  queueSize = 5,
Reusability  reuse = AddressIsExclusive 
)
Parameters
socketsSocket(s) to listen on
numSocketsNumber of sockets to listen on consecutive ports
bindingLocal interface address to bind to.
queueSizeNumber of pending accepts that may be queued.
reuseCan/Can't listen more than once.
void PIPSocket::PortRange::Set ( unsigned  newBase,
unsigned  newMax,
unsigned  dfltRange = 0,
unsigned  dfltBase = 0 
)

Set the port range parameters.

Parameters
newBaseNew base port
newMaxNew maximum port, if < newBase, then set to newBase
dfltRangeIf newMax == 0 then it is set to newBase plus this.
dfltBaseIf newbase == 0, then it is set to this value.

Friends And Related Function Documentation

ostream& operator<< ( ostream &  strm,
const PortRange pr 
)
friend

Member Data Documentation

WORD PIPSocket::PortRange::m_base
protected

Referenced by GetBase(), and IsValid().

WORD PIPSocket::PortRange::m_max
protected

Referenced by GetMax(), and IsValid().

PMutex PIPSocket::PortRange::m_mutex
protected

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