Claw 1.7.3
socket_server.cpp
Go to the documentation of this file.
1/*
2 CLAW - a C++ Library Absolutely Wonderful
3
4 CLAW is a free library without any particular aim but being useful to
5 anyone.
6
7 Copyright (C) 2005-2011 Julien Jorge
8
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or (at your option) any later version.
13
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with this library; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
23 contact: julien.jorge@gamned.org
24*/
31#include <sys/types.h>
32
33/*----------------------------------------------------------------------------*/
39{
40 // nothing to do
41} // socket_server::socket_server()
42
43/*----------------------------------------------------------------------------*/
49claw::net::socket_server::socket_server( int port, unsigned int queue_size )
50{
51 open(port, queue_size);
52} // socket_server::socket_server()
53
54/*----------------------------------------------------------------------------*/
62claw::net::socket_server::open( int port, unsigned int queue_size )
63{
64 socket_server* result = NULL;
65
66 if ( basic_socket::open() )
67 {
68 if ( !socket_traits::listen(m_descriptor, port, queue_size) )
70 else
71 result = this;
72 }
73
74 return result;
75} // socket_server::open()
76
77/*----------------------------------------------------------------------------*/
82{
83 if ( basic_socket::close() )
84 return this;
85 else
86 return NULL;
87} // socket_server::close()
88
89/*----------------------------------------------------------------------------*/
94{
95 return basic_socket::is_open();
96} // socket_server::is_open()
97
98/*----------------------------------------------------------------------------*/
102claw::net::socket_server::operator bool() const
103{
104 return is_open();
105} // socket_server::operator bool()
106
107/*----------------------------------------------------------------------------*/
113{
114 return socket_traits::init();
115} // socket_server::init()
116
117/*----------------------------------------------------------------------------*/
123{
124 return socket_traits::release();
125} // socket_server::release()
basic_socket * open()
Open the socket.
basic_socket * close()
Close the socket.
bool is_open() const
Tell if the socket is open.
Class used to receive incoming connections.
static bool release()
Close the socket library.
static bool init()
Initialize the use of the socket library.
socket_server * close()
Close the socket.
bool is_open() const
Tell if the server is open.
static bool listen(descriptor d, int port, unsigned int queue_size)
Open a socket for incoming connexions.
static bool release()
Close the socket library.
static bool init()
Initialize the use of the socket library.
Class used to receive incoming connections.