# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

NLNET::CListenSock Class Reference

CListenSock: listening socket for servers. More...

#include <listen_sock.h>

Inheritance diagram for NLNET::CListenSock:

NLNET::CTcpSock NLNET::CSock List of all members.

Public Methods

 CListenSock ()
 Constructor. More...

CTcpSockaccept ()
 Blocks until an incoming connection is requested, accepts it, and creates a new socket (you have to delete it after use). More...

Socket setup
void init (uint16 port)
 Prepares to receive connections on a specified port (bind+listen). More...

void init (const CInetAddress &addr)
 Prepares to receive connections on a specified address/port (useful when the host has several addresses). More...

void setBacklog (sint backlog)
 Sets the number of the pending connections queue, or -1 for the maximum possible value. More...

sint backlog () const
 Returns the pending connections queue. More...


Private Attributes

bool _Bound
sint _BackLog

Detailed Description

CListenSock: listening socket for servers.

How to accept connections in a simple server:

  1. Create a CListenSock object
  2. Listen on the port you want the clients to connect
  3. In a loop, accept a connection and store the new socket
Author:
Olivier Cado , Nevrax France
Date:
2000-2001

Definition at line 47 of file listen_sock.h.


Constructor & Destructor Documentation

NLNET::CListenSock::CListenSock  
 

Constructor.

Definition at line 62 of file listen_sock.cpp.

References NLNET::CSock::createSocket, and setBacklog.


Member Function Documentation

CTcpSock * NLNET::CListenSock::accept  
 

Blocks until an incoming connection is requested, accepts it, and creates a new socket (you have to delete it after use).

Definition at line 128 of file listen_sock.cpp.

References NLNET::CSock::_Sock, NLNET::CTcpSock::CTcpSock, and nldebug.

sint NLNET::CListenSock::backlog   const [inline]
 

Returns the pending connections queue.

Definition at line 67 of file listen_sock.h.

References _BackLog, and sint.

Referenced by setBacklog.

void NLNET::CListenSock::init const CInetAddress   addr
 

Prepares to receive connections on a specified address/port (useful when the host has several addresses).

Definition at line 92 of file listen_sock.cpp.

References _BackLog, _Bound, NLNET::CSock::_LocalAddr, NLNET::CSock::_Sock, and nldebug.

void NLNET::CListenSock::init uint16    port
 

Prepares to receive connections on a specified port (bind+listen).

Definition at line 75 of file listen_sock.cpp.

References NLNET::CSock::_LocalAddr, NLNET::CSock::_Sock, nldebug, and uint16.

void NLNET::CListenSock::setBacklog sint    backlog
 

Sets the number of the pending connections queue, or -1 for the maximum possible value.

Definition at line 157 of file listen_sock.cpp.

References _BackLog, NLNET::CSock::_Sock, backlog, and sint.

Referenced by CListenSock.


Member Data Documentation

sint NLNET::CListenSock::_BackLog [private]
 

Definition at line 78 of file listen_sock.h.

Referenced by backlog, init, and setBacklog.

bool NLNET::CListenSock::_Bound [private]
 

Definition at line 76 of file listen_sock.h.

Referenced by init.


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