claw
1.9.0
Toggle main menu visibility
Loading...
Searching...
No Matches
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@stuff-o-matic.com
24
*/
30
#include <
claw/net/basic_socket.hpp
>
31
36
claw::net::basic_socket::basic_socket
()
37
:
m_descriptor
(socket_traits::invalid_socket)
38
{}
39
44
claw::net::basic_socket
*
claw::net::basic_socket::open
()
45
{
46
basic_socket
* result = NULL;
47
48
m_descriptor
=
socket_traits::open
();
49
50
if
(
socket_traits::valid_descriptor
(
m_descriptor
))
51
result =
this
;
52
53
return
result;
54
}
55
60
claw::net::basic_socket
*
claw::net::basic_socket::close
()
61
{
62
basic_socket
* result =
this
;
63
64
if
(
is_open
())
65
{
66
if
(
socket_traits::close
(
m_descriptor
))
67
m_descriptor
=
socket_traits::invalid_socket
;
68
else
69
result = NULL;
70
}
71
72
return
result;
73
}
74
78
bool
claw::net::basic_socket::is_open
()
const
79
{
80
return
socket_traits::valid_descriptor
(
m_descriptor
);
81
}
basic_socket.hpp
Common interface for claw::net::basic_socketbuf and claw::net::socket_server.
claw::net::basic_socket
Common interface for claw::net::basic_socketbuf and claw::net::socket_server.
Definition
basic_socket.hpp:48
claw::net::basic_socket::basic_socket
basic_socket()
Constructor.
Definition
basic_socket.cpp:36
claw::net::basic_socket::open
basic_socket * open()
Open the socket.
Definition
basic_socket.cpp:44
claw::net::basic_socket::close
basic_socket * close()
Close the socket.
Definition
basic_socket.cpp:60
claw::net::basic_socket::is_open
bool is_open() const
Tell if the socket is open.
Definition
basic_socket.cpp:78
claw::net::basic_socket::m_descriptor
socket_traits::descriptor m_descriptor
File descriptor.
Definition
basic_socket.hpp:59
claw::socket_traits_unix::open
static descriptor open()
Open a socket.
Definition
socket_traits_unix.hpp:83
claw::socket_traits_unix::invalid_socket
static const descriptor invalid_socket
Invalid socket descriptor.
Definition
socket_traits_unix.hpp:58
claw::socket_traits_unix::close
static bool close(descriptor d)
Close a socket.
Definition
socket_traits_unix.hpp:97
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:203
lib
net
src
claw
net
basic_socket.cpp
Generated by
1.17.0