nSocketListener Class Reference

collection of listening server sockets More...

#include <nSocket.h>

Collaboration diagram for nSocketListener:

Collaboration graph
[legend]

List of all members.

Public Types

typedef std::vector< nSocketSocketArray
 array of sockets
typedef SocketArray::const_iterator const_iterator
 iterator in that array
typedef SocketArray::const_iterator iterator
 iterator in that array

Public Member Functions

 nSocketListener ()
 constructor
 ~nSocketListener ()
 destructor
bool Listen (bool state)
 enables/disables listening state
iterator begin () const
 returns iterator to first socket
iterator end () const
 returns iterator to end of sockets
nSocketListenerSetPort (unsigned int port)
 Sets the network port to listen on.
unsigned int GetPort (void) const
 Gets the network port to listen on.
nSocketListener const & GetPort (unsigned int &port) const
 Gets the network port to listen on.
nSocketListenerSetIpList (tString const &ipList)
 Sets list of IPs to bind to.
tString const & GetIpList (void) const
 Gets list of IPs to bind to.
nSocketListener const & GetIpList (tString &ipList) const
 Gets list of IPs to bind to.
SocketArray const & GetSockets (void) const
 Gets the listening sockets.
nSocketListener const & GetSockets (SocketArray &sockets) const
 Gets the listening sockets.

Private Member Functions

 nSocketListener (const nSocketListener &)
nSocketListeneroperator= (const nSocketListener &)
nSocketListenerSetSockets (SocketArray const &sockets)
 Sets the listening sockets.

Private Attributes

SocketArray sockets_
 the listening sockets
unsigned int port_
 the network port to listen on
tString ipList_
 list of IPs to bind to


Detailed Description

collection of listening server sockets

Definition at line 184 of file nSocket.h.


Member Typedef Documentation

typedef std::vector< nSocket > nSocketListener::SocketArray

array of sockets

Definition at line 192 of file nSocket.h.

typedef SocketArray::const_iterator nSocketListener::const_iterator

iterator in that array

Definition at line 193 of file nSocket.h.

typedef SocketArray::const_iterator nSocketListener::iterator

iterator in that array

Definition at line 194 of file nSocket.h.


Constructor & Destructor Documentation

nSocketListener::nSocketListener ( void   ) 

constructor

Definition at line 2330 of file nSocket.cpp.

02333         : port_( 0 ), ipList_( "ANY" )

nSocketListener::~nSocketListener ( void   ) 

destructor

Definition at line 2344 of file nSocket.cpp.

References Listen().

02347 {
02348     // not really required since the sockets close themselves automatically, but stop listening anyway

Here is the call graph for this function:

nSocketListener::nSocketListener ( const nSocketListener  )  [private]


Member Function Documentation

bool nSocketListener::Listen ( bool  state  ) 

enables/disables listening state

Parameters:
state listening state ( on or off )
Returns:
true on success

Definition at line 2361 of file nSocket.cpp.

References ANET_Listen(), ipList_, port_, and sockets_.

Referenced by SetIpList(), SetPort(), sg_HostGame(), nBasicNetworkSystem::Shutdown(), sn_Listen(), and ~nSocketListener().

02364 {
02365     bool ret = false;
02366     try{
02367         // delegate to helper function
02368         ret = ANET_Listen( state, port_, ipList_, sockets_ );
02369     }
02370     catch ( OneSocketOpened const & )
02371     {
02372         // only one socket was upened on user request; this counts as succes
02373         ret = true;
02374     }
02375 
02376     // close sockets if opening failed
02377     if ( state && !ret )
02378         Listen( false );
02379 
02380     // return result

Here is the call graph for this function:

Here is the caller graph for this function:

nSocketListener::iterator nSocketListener::begin ( void   )  const

returns iterator to first socket

Returns:
iterator to the beginning of the sockets

Definition at line 2392 of file nSocket.cpp.

References sockets_.

Referenced by nServerInfo::TellMasterAboutMe().

02395 {

Here is the caller graph for this function:

nSocketListener::iterator nSocketListener::end ( void   )  const

returns iterator to end of sockets

Returns:
iterator past the end of the sockets

Definition at line 2407 of file nSocket.cpp.

References sockets_.

Referenced by nServerInfo::TellMasterAboutMe().

02410 {

Here is the caller graph for this function:

nSocketListener & nSocketListener::SetPort ( unsigned int  port  ) 

Sets the network port to listen on.

Parameters:
port the network port to listen on to set
Returns:
A reference to this to allow chaining

Definition at line 2455 of file nSocket.cpp.

References Listen(), and port_.

Referenced by sn_Listen().

02458 {
02459     Listen( false );
02460 
02461     this->port_ = port;

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int nSocketListener::GetPort ( void   )  const

Gets the network port to listen on.

Returns:
the network port to listen on

Definition at line 2422 of file nSocket.cpp.

References port_.

02425 {

nSocketListener const & nSocketListener::GetPort ( unsigned int &  port  )  const

Gets the network port to listen on.

Parameters:
port the network port to listen on to fill
Returns:
A reference to this to allow chaining

Definition at line 2438 of file nSocket.cpp.

References port_.

02441 {
02442     port = this->port_;

nSocketListener & nSocketListener::SetIpList ( tString const &  ipList  ) 

Sets list of IPs to bind to.

Parameters:
ipList list of IPs to bind to to set
Returns:
A reference to this to allow chaining

Definition at line 2506 of file nSocket.cpp.

References ipList_, and Listen().

Referenced by sn_Listen().

02509 {
02510     Listen( false );
02511 
02512     this->ipList_ = ipList;

Here is the call graph for this function:

Here is the caller graph for this function:

tString const & nSocketListener::GetIpList ( void   )  const

Gets list of IPs to bind to.

Returns:
list of IPs to bind to

Definition at line 2473 of file nSocket.cpp.

References ipList_.

02476 {

nSocketListener const & nSocketListener::GetIpList ( tString ipList  )  const

Gets list of IPs to bind to.

Parameters:
ipList list of IPs to bind to to fill
Returns:
A reference to this to allow chaining

Definition at line 2489 of file nSocket.cpp.

References ipList_.

02492 {
02493     ipList = this->ipList_;

nSocketListener::SocketArray const & nSocketListener::GetSockets ( void   )  const [inline]

Gets the listening sockets.

Returns:
the listening sockets

Definition at line 262 of file nSocket.h.

References sockets_.

Referenced by nBasicNetworkSystem::Select().

00263 {
00264     return this->sockets_;
00265 }

Here is the caller graph for this function:

nSocketListener const & nSocketListener::GetSockets ( SocketArray sockets  )  const [inline]

Gets the listening sockets.

Parameters:
sockets the listening sockets to fill
Returns:
A reference to this to allow chaining

Definition at line 278 of file nSocket.h.

References sockets_.

00279 {
00280     sockets = this->sockets_;
00281     return *this;
00282 }

nSocketListener& nSocketListener::operator= ( const nSocketListener  )  [private]

nSocketListener & nSocketListener::SetSockets ( SocketArray const &  sockets  )  [inline, private]

Sets the listening sockets.

Parameters:
sockets the listening sockets to set
Returns:
A reference to this to allow chaining

Definition at line 295 of file nSocket.h.

References sockets_.

00296 {
00297     this->sockets_ = sockets;
00298     return *this;
00299 }


Member Data Documentation

SocketArray nSocketListener::sockets_ [private]

the listening sockets

Definition at line 209 of file nSocket.h.

Referenced by begin(), end(), GetSockets(), Listen(), and SetSockets().

unsigned int nSocketListener::port_ [private]

the network port to listen on

Definition at line 210 of file nSocket.h.

Referenced by GetPort(), Listen(), and SetPort().

tString nSocketListener::ipList_ [private]

list of IPs to bind to

Definition at line 211 of file nSocket.h.

Referenced by GetIpList(), Listen(), and SetIpList().


The documentation for this class was generated from the following files:
Generated on Sat Mar 15 23:50:56 2008 for Armagetron Advanced by  doxygen 1.5.4