claw 1.9.0
 
Loading...
Searching...
No Matches
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@stuff-o-matic.com
24*/
31
32#include <sys/types.h>
33
39{
40 // nothing to do
41}
42
48claw::net::socket_server::socket_server(int port, unsigned int queue_size)
49{
50 open(port, queue_size);
51}
52
60claw::net::socket_server::open(int port, unsigned int queue_size)
61{
62 socket_server* result = NULL;
63
65 {
66 if(!socket_traits::listen(m_descriptor, port, queue_size))
68 else
69 result = this;
70 }
71
72 return result;
73}
74
79{
81 return this;
82 else
83 return NULL;
84}
85
93
97claw::net::socket_server::operator bool() const
98{
99 return is_open();
100}
101
110
basic_socket * open()
Open the socket.
basic_socket * close()
Close the socket.
bool is_open() const
Tell if the socket is open.
socket_traits::descriptor m_descriptor
File descriptor.
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.
socket_server * open(int port, unsigned int queue_size=s_default_queue_size)
Open 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.