2
CLAW - a C++ Library Absolutely Wonderful
4
CLAW is a free library without any particular aim but being useful to
7
Copyright (C) 2005-2008 Julien Jorge
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.
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.
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
23
contact: julien_jorge@yahoo.fr
26
* \file basic_socket.cpp
27
* \brief Implementation of the claw::net::basic_socket class.
28
* \author Julien Jorge
30
#include <claw/basic_socket.hpp>
32
/*----------------------------------------------------------------------------*/
35
* \post is_open() == false
37
claw::net::basic_socket::basic_socket()
38
: m_descriptor(socket_traits::invalid_socket)
41
} // basic_socket::basic_socket()
43
/*----------------------------------------------------------------------------*/
45
* \brief Open the socket.
46
* \return this is everything works fine, NULL otherwise.
48
claw::net::basic_socket::basic_socket* claw::net::basic_socket::open()
50
basic_socket* result = NULL;
52
m_descriptor = socket_traits::open();
54
if ( socket_traits::valid_descriptor( m_descriptor ) )
58
} // basic_socket::open()
60
/*----------------------------------------------------------------------------*/
62
* \brief Close the socket.
63
* \return this if everything works fine, NULL otherwise.
65
claw::net::basic_socket::basic_socket* claw::net::basic_socket::close()
67
basic_socket* result = this;
71
if ( socket_traits::close(m_descriptor) )
72
m_descriptor = socket_traits::invalid_socket;
78
} // basic_socket::close()
80
/*----------------------------------------------------------------------------*/
82
* \brief Tell if the socket is open.
84
bool claw::net::basic_socket::is_open() const
86
return socket_traits::valid_descriptor(m_descriptor);
87
} // basic_socket::is_open()