#include <nSocket.h>
Public Types | |
typedef std::vector< nSocket > | SocketArray |
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 | |
nSocketListener & | SetPort (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. | |
nSocketListener & | SetIpList (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 &) | |
nSocketListener & | operator= (const nSocketListener &) |
nSocketListener & | SetSockets (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 |
Definition at line 184 of file nSocket.h.
typedef std::vector< nSocket > nSocketListener::SocketArray |
typedef SocketArray::const_iterator nSocketListener::const_iterator |
typedef SocketArray::const_iterator nSocketListener::iterator |
nSocketListener::nSocketListener | ( | void | ) |
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
nSocketListener::nSocketListener | ( | const nSocketListener & | ) | [private] |
bool nSocketListener::Listen | ( | bool | state | ) |
enables/disables listening state
state | listening state ( on or off ) |
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
nSocketListener::iterator nSocketListener::begin | ( | void | ) | const |
returns iterator to first socket
Definition at line 2392 of file nSocket.cpp.
References sockets_.
Referenced by nServerInfo::TellMasterAboutMe().
nSocketListener::iterator nSocketListener::end | ( | void | ) | const |
returns iterator to end of sockets
Definition at line 2407 of file nSocket.cpp.
References sockets_.
Referenced by nServerInfo::TellMasterAboutMe().
nSocketListener & nSocketListener::SetPort | ( | unsigned int | port | ) |
Sets the network port to listen on.
port | the network port to listen on to set |
Definition at line 2455 of file nSocket.cpp.
References Listen(), and port_.
Referenced by sn_Listen().
unsigned int nSocketListener::GetPort | ( | void | ) | const |
Gets the network port to listen on.
Definition at line 2422 of file nSocket.cpp.
References port_.
nSocketListener const & nSocketListener::GetPort | ( | unsigned int & | port | ) | const |
Gets the network port to listen on.
port | the network port to listen on to fill |
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.
ipList | list of IPs to bind to to set |
Definition at line 2506 of file nSocket.cpp.
References ipList_, and Listen().
Referenced by sn_Listen().
tString const & nSocketListener::GetIpList | ( | void | ) | const |
Gets list of IPs to bind to.
Definition at line 2473 of file nSocket.cpp.
References ipList_.
nSocketListener const & nSocketListener::GetIpList | ( | tString & | ipList | ) | const |
Gets list of IPs to bind to.
ipList | list of IPs to bind to to fill |
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.
Definition at line 262 of file nSocket.h.
References sockets_.
Referenced by nBasicNetworkSystem::Select().
00263 { 00264 return this->sockets_; 00265 }
nSocketListener const & nSocketListener::GetSockets | ( | SocketArray & | sockets | ) | const [inline] |
nSocketListener& nSocketListener::operator= | ( | const nSocketListener & | ) | [private] |
nSocketListener & nSocketListener::SetSockets | ( | SocketArray const & | sockets | ) | [inline, private] |
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] |
tString nSocketListener::ipList_ [private] |
list of IPs to bind to
Definition at line 211 of file nSocket.h.
Referenced by GetIpList(), Listen(), and SetIpList().