Claw
1.7.3
code
basic_socket.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
*/
30
#include <
claw/basic_socket.hpp
>
31
32
/*----------------------------------------------------------------------------*/
37
claw::net::basic_socket::basic_socket
()
38
: m_descriptor(
socket_traits
::invalid_socket)
39
{
40
41
}
// basic_socket::basic_socket()
42
43
/*----------------------------------------------------------------------------*/
48
claw::net::basic_socket
*
claw::net::basic_socket::open
()
49
{
50
basic_socket
* result = NULL;
51
52
m_descriptor =
socket_traits::open
();
53
54
if
(
socket_traits::valid_descriptor
( m_descriptor ) )
55
result =
this
;
56
57
return
result;
58
}
// basic_socket::open()
59
60
/*----------------------------------------------------------------------------*/
65
claw::net::basic_socket
*
claw::net::basic_socket::close
()
66
{
67
basic_socket
* result =
this
;
68
69
if
( is_open() )
70
{
71
if
(
socket_traits::close
(m_descriptor) )
72
m_descriptor =
socket_traits::invalid_socket
;
73
else
74
result = NULL;
75
}
76
77
return
result;
78
}
// basic_socket::close()
79
80
/*----------------------------------------------------------------------------*/
84
bool
claw::net::basic_socket::is_open
()
const
85
{
86
return
socket_traits::valid_descriptor
(m_descriptor);
87
}
// basic_socket::is_open()
88
claw::socket_traits_unix::close
static bool close(descriptor d)
Close a socket.
Definition:
socket_traits_unix.hpp:101
claw::net::basic_socket::basic_socket
basic_socket()
Constructor.
Definition:
basic_socket.cpp:37
claw::net::basic_socket::is_open
bool is_open() const
Tell if the socket is open.
Definition:
basic_socket.cpp:84
claw::socket_traits_unix
Unix interface for using sockets.
Definition:
socket_traits_unix.hpp:50
claw::socket_traits_unix::open
static descriptor open()
Open a socket.
Definition:
socket_traits_unix.hpp:86
basic_socket.hpp
Common interface for claw::net::basic_socketbuf and claw::net::socket_server.
claw::net::basic_socket::open
basic_socket * open()
Open the socket.
Definition:
basic_socket.cpp:48
claw::socket_traits_unix::invalid_socket
static const descriptor invalid_socket
Invalid socket descriptor.
Definition:
socket_traits_unix.hpp:58
claw::net::basic_socket
Common interface for claw::net::basic_socketbuf and claw::net::socket_server.
Definition:
basic_socket.hpp:46
claw::socket_traits_unix::valid_descriptor
static bool valid_descriptor(descriptor d)
Tell if a descriptor is a valid socket descriptor.
Definition:
socket_traits_unix.hpp:212
claw::net::basic_socket::close
basic_socket * close()
Close the socket.
Definition:
basic_socket.cpp:65
Generated on Mon Apr 25 2022 14:03:04 for Claw by
1.8.17