PTLib
Version 2.18.8
|
Class for handling a range of ports for local binding. More...
#include <ipsock.h>
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 Member Functions | |
PDECLARE_MUTEX (m_mutex) | |
Protected Attributes | |
WORD | m_base |
WORD | m_max |
Friends | |
ostream & | operator<< (ostream &strm, const PortRange &pr) |
Class for handling a range of ports for local binding.
PIPSocket::PortRange::PortRange | ( | WORD | basePort = 0 , |
WORD | maxPort = 0 |
||
) |
bool PIPSocket::PortRange::Connect | ( | PIPSocket & | socket, |
const Address & | addr, | ||
const Address & | binding = GetDefaultIpAny() |
||
) |
Connect to remote.
socket | Socket to connect on |
addr | Address of remote machine to connect to. |
binding | Local interface address to bind to. |
|
inline |
Get base port for range.
References m_base.
|
inline |
Get maximum port for range.
References 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.
socket | Socket to listen on |
binding | Local interface address to bind to. |
queueSize | Number of pending accepts that may be queued. |
reuse | Can/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 |
||
) |
sockets | Socket(s) to listen on |
numSockets | Number of sockets to listen on consecutive ports |
binding | Local interface address to bind to. |
queueSize | Number of pending accepts that may be queued. |
reuse | Can/Can't listen more than once. |
|
protected |
void PIPSocket::PortRange::Set | ( | unsigned | newBase, |
unsigned | newMax, | ||
unsigned | dfltRange = 0 , |
||
unsigned | dfltBase = 0 |
||
) |
Set the port range parameters.
newBase | New base port |
newMax | New maximum port, if < newBase, then set to newBase |
dfltRange | If newMax == 0 then it is set to newBase plus this. |
dfltBase | If newbase == 0, then it is set to this value. |
|
friend |