Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
actor-incubator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
actor-incubator
Commits
5e32089a
Unverified
Commit
5e32089a
authored
Jul 28, 2019
by
Dominik Charousset
Committed by
GitHub
Jul 28, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7
Add datagram_socket class
parents
e93565f4
e8b6b150
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
150 additions
and
1 deletion
+150
-1
libcaf_net/CMakeLists.txt
libcaf_net/CMakeLists.txt
+1
-0
libcaf_net/caf/net/datagram_socket.hpp
libcaf_net/caf/net/datagram_socket.hpp
+53
-0
libcaf_net/caf/net/socket.hpp
libcaf_net/caf/net/socket.hpp
+1
-1
libcaf_net/src/datagram_socket.cpp
libcaf_net/src/datagram_socket.cpp
+64
-0
libcaf_net/test/datagram_socket.cpp
libcaf_net/test/datagram_socket.cpp
+31
-0
No files found.
libcaf_net/CMakeLists.txt
View file @
5e32089a
...
...
@@ -8,6 +8,7 @@ file(GLOB_RECURSE LIBCAF_NET_HDRS "caf/*.hpp")
# list cpp files excluding platform-dependent files
set
(
LIBCAF_NET_SRCS
src/actor_proxy_impl.cpp
src/datagram_socket.cpp
src/endpoint_manager.cpp
src/host.cpp
src/multiplexer.cpp
...
...
libcaf_net/caf/net/datagram_socket.hpp
0 → 100644
View file @
5e32089a
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright 2011-2019 Dominik Charousset *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#pragma once
#include "caf/net/network_socket.hpp"
#include "caf/variant.hpp"
namespace
caf
{
namespace
net
{
/// A datagram-oriented network communication endpoint.
struct
datagram_socket
:
abstract_socket
<
datagram_socket
>
{
using
super
=
abstract_socket
<
datagram_socket
>
;
using
super
::
super
;
constexpr
operator
socket
()
const
noexcept
{
return
socket
{
id
};
}
constexpr
operator
network_socket
()
const
noexcept
{
return
network_socket
{
id
};
}
};
/// Enables or disables `SIO_UDP_CONNRESET` error on `x`.
/// @relates datagram_socket
error
allow_connreset
(
datagram_socket
x
,
bool
new_value
);
/// Converts the result from I/O operation on a ::datagram_socket to either an
/// error code or a integer greater or equal to zero.
/// @relates datagram_socket
variant
<
size_t
,
sec
>
check_datagram_socket_io_res
(
std
::
make_signed
<
size_t
>::
type
res
);
}
// namespace net
}
// namespace caf
libcaf_net/caf/net/socket.hpp
View file @
5e32089a
...
...
@@ -31,7 +31,7 @@ namespace caf {
namespace
net
{
/// An internal endpoint for sending or receiving data. Can be either a
/// ::network_socket
or a ::pipe
_socket.
/// ::network_socket
, ::pipe_socket, ::stream_socket, or ::datagram
_socket.
struct
socket
:
abstract_socket
<
socket
>
{
using
super
=
abstract_socket
<
socket
>
;
...
...
libcaf_net/src/datagram_socket.cpp
0 → 100644
View file @
5e32089a
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright 2011-2019 Dominik Charousset *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#include "caf/net/datagram_socket.hpp"
#include "caf/detail/net_syscall.hpp"
#include "caf/detail/socket_sys_includes.hpp"
#include "caf/logger.hpp"
namespace
caf
{
namespace
net
{
#ifdef CAF_WINDOWS
error
allow_connreset
(
datagram_socket
x
,
bool
new_value
)
{
CAF_LOG_TRACE
(
CAF_ARG
(
x
)
<<
CAF_ARG
(
new_value
));
DWORD
bytes_returned
=
0
;
CAF_NET_SYSCALL
(
"WSAIoctl"
,
res
,
!=
,
0
,
WSAIoctl
(
x
.
id
,
_WSAIOW
(
IOC_VENDOR
,
12
),
&
new_value
,
sizeof
(
new_value
),
NULL
,
0
,
&
bytes_returned
,
NULL
,
NULL
));
return
none
;
}
#else // CAF_WINDOWS
error
allow_connreset
(
datagram_socket
x
,
bool
)
{
if
(
x
==
invalid_socket
)
return
sec
::
socket_invalid
;
// nop; SIO_UDP_CONNRESET only exists on Windows
return
none
;
}
#endif // CAF_WINDOWS
variant
<
size_t
,
sec
>
check_datagram_socket_io_res
(
std
::
make_signed
<
size_t
>::
type
res
)
{
if
(
res
<
0
)
{
auto
code
=
last_socket_error
();
if
(
code
==
std
::
errc
::
operation_would_block
||
code
==
std
::
errc
::
resource_unavailable_try_again
)
return
sec
::
unavailable_or_would_block
;
return
sec
::
socket_operation_failed
;
}
return
static_cast
<
size_t
>
(
res
);
}
}
// namespace net
}
// namespace caf
libcaf_net/test/datagram_socket.cpp
0 → 100644
View file @
5e32089a
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright 2011-2019 Dominik Charousset *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#define CAF_SUITE datagram_socket
#include "caf/net/datagram_socket.hpp"
#include "caf/test/dsl.hpp"
using
namespace
caf
;
using
namespace
caf
::
net
;
CAF_TEST
(
invalid_socket
)
{
datagram_socket
x
;
CAF_CHECK_NOT_EQUAL
(
allow_connreset
(
x
,
true
),
none
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment