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
2b82a667
Commit
2b82a667
authored
Dec 18, 2019
by
Jakob Otto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add export declarations to net headers
parent
b9c3d091
Changes
17
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
96 additions
and
71 deletions
+96
-71
libcaf_net/caf/net/backend/test.hpp
libcaf_net/caf/net/backend/test.hpp
+2
-1
libcaf_net/caf/net/datagram_socket.hpp
libcaf_net/caf/net/datagram_socket.hpp
+4
-3
libcaf_net/caf/net/endpoint_manager.hpp
libcaf_net/caf/net/endpoint_manager.hpp
+2
-1
libcaf_net/caf/net/host.hpp
libcaf_net/caf/net/host.hpp
+2
-1
libcaf_net/caf/net/ip.hpp
libcaf_net/caf/net/ip.hpp
+6
-5
libcaf_net/caf/net/make_endpoint_manager.hpp
libcaf_net/caf/net/make_endpoint_manager.hpp
+3
-2
libcaf_net/caf/net/middleman.hpp
libcaf_net/caf/net/middleman.hpp
+2
-1
libcaf_net/caf/net/network_socket.hpp
libcaf_net/caf/net/network_socket.hpp
+13
-12
libcaf_net/caf/net/packet_writer.hpp
libcaf_net/caf/net/packet_writer.hpp
+2
-1
libcaf_net/caf/net/pipe_socket.hpp
libcaf_net/caf/net/pipe_socket.hpp
+6
-5
libcaf_net/caf/net/receive_policy.hpp
libcaf_net/caf/net/receive_policy.hpp
+6
-2
libcaf_net/caf/net/socket.hpp
libcaf_net/caf/net/socket.hpp
+10
-8
libcaf_net/caf/net/stream_socket.hpp
libcaf_net/caf/net/stream_socket.hpp
+12
-9
libcaf_net/caf/net/tcp_accept_socket.hpp
libcaf_net/caf/net/tcp_accept_socket.hpp
+7
-6
libcaf_net/caf/net/tcp_stream_socket.hpp
libcaf_net/caf/net/tcp_stream_socket.hpp
+5
-3
libcaf_net/caf/net/test/host_fixture.hpp
libcaf_net/caf/net/test/host_fixture.hpp
+2
-1
libcaf_net/caf/net/udp_datagram_socket.hpp
libcaf_net/caf/net/udp_datagram_socket.hpp
+12
-10
No files found.
libcaf_net/caf/net/backend/test.hpp
View file @
2b82a667
...
...
@@ -20,6 +20,7 @@
#include <map>
#include "caf/detail/net_export.hpp"
#include "caf/net/endpoint_manager.hpp"
#include "caf/net/fwd.hpp"
#include "caf/net/middleman_backend.hpp"
...
...
@@ -30,7 +31,7 @@ namespace caf::net::backend {
/// Minimal backend for unit testing.
/// @warning this backend is *not* thread safe.
class
test
:
public
middleman_backend
{
class
CAF_NET_EXPORT
test
:
public
middleman_backend
{
public:
// -- member types -----------------------------------------------------------
...
...
libcaf_net/caf/net/datagram_socket.hpp
View file @
2b82a667
...
...
@@ -18,13 +18,14 @@
#pragma once
#include "caf/detail/net_export.hpp"
#include "caf/net/network_socket.hpp"
#include "caf/variant.hpp"
namespace
caf
::
net
{
/// A datagram-oriented network communication endpoint.
struct
datagram_socket
:
network_socket
{
struct
CAF_NET_EXPORT
datagram_socket
:
network_socket
{
using
super
=
network_socket
;
using
super
::
super
;
...
...
@@ -32,12 +33,12 @@ struct datagram_socket : network_socket {
/// Enables or disables `SIO_UDP_CONNRESET` error on `x`.
/// @relates datagram_socket
error
allow_connreset
(
datagram_socket
x
,
bool
new_value
);
error
CAF_NET_EXPORT
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
>
variant
<
size_t
,
sec
>
CAF_NET_EXPORT
check_datagram_socket_io_res
(
std
::
make_signed
<
size_t
>::
type
res
);
}
// namespace caf::net
libcaf_net/caf/net/endpoint_manager.hpp
View file @
2b82a667
...
...
@@ -25,6 +25,7 @@
#include "caf/actor.hpp"
#include "caf/actor_clock.hpp"
#include "caf/byte.hpp"
#include "caf/detail/net_export.hpp"
#include "caf/fwd.hpp"
#include "caf/intrusive/drr_queue.hpp"
#include "caf/intrusive/fifo_inbox.hpp"
...
...
@@ -37,7 +38,7 @@
namespace
caf
::
net
{
/// Manages a communication endpoint.
class
endpoint_manager
:
public
socket_manager
{
class
CAF_NET_EXPORT
endpoint_manager
:
public
socket_manager
{
public:
// -- member types -----------------------------------------------------------
...
...
libcaf_net/caf/net/host.hpp
View file @
2b82a667
...
...
@@ -18,11 +18,12 @@
#pragma once
#include "caf/detail/net_export.hpp"
#include "caf/fwd.hpp"
namespace
caf
::
net
{
struct
this_host
{
struct
CAF_NET_EXPORT
this_host
{
/// Initializes the network subsystem.
static
error
startup
();
...
...
libcaf_net/caf/net/ip.hpp
View file @
2b82a667
...
...
@@ -21,24 +21,25 @@
#include <string>
#include <vector>
#include "caf/detail/net_export.hpp"
#include "caf/fwd.hpp"
namespace
caf
::
net
::
ip
{
/// Returns all IP addresses of `host` (if any).
std
::
vector
<
ip_address
>
resolve
(
string_view
host
);
std
::
vector
<
ip_address
>
CAF_NET_EXPORT
resolve
(
string_view
host
);
/// Returns all IP addresses of `host` (if any).
std
::
vector
<
ip_address
>
resolve
(
ip_address
host
);
std
::
vector
<
ip_address
>
CAF_NET_EXPORT
resolve
(
ip_address
host
);
/// Returns the IP addresses for a local endpoint, which is either an address,
/// an interface name, or the string "localhost".
std
::
vector
<
ip_address
>
local_addresses
(
string_view
host
);
std
::
vector
<
ip_address
>
CAF_NET_EXPORT
local_addresses
(
string_view
host
);
/// Returns the IP addresses for a local endpoint address.
std
::
vector
<
ip_address
>
local_addresses
(
ip_address
host
);
std
::
vector
<
ip_address
>
CAF_NET_EXPORT
local_addresses
(
ip_address
host
);
/// Returns the hostname of this device.
std
::
string
hostname
();
std
::
string
CAF_NET_EXPORT
hostname
();
}
// namespace caf::net::ip
libcaf_net/caf/net/make_endpoint_manager.hpp
View file @
2b82a667
...
...
@@ -18,6 +18,7 @@
#pragma once
#include "caf/detail/net_export.hpp"
#include "caf/make_counted.hpp"
#include "caf/net/endpoint_manager.hpp"
#include "caf/net/endpoint_manager_impl.hpp"
...
...
@@ -25,8 +26,8 @@
namespace
caf
::
net
{
template
<
class
Transport
>
endpoint_manager_ptr
make_endpoint_manager
(
const
multiplexer_ptr
&
mpx
,
actor_system
&
sys
,
Transport
trans
)
{
endpoint_manager_ptr
CAF_NET_EXPORT
make_endpoint_manager
(
const
multiplexer_ptr
&
mpx
,
actor_system
&
sys
,
Transport
trans
)
{
using
impl
=
endpoint_manager_impl
<
Transport
>
;
return
make_counted
<
impl
>
(
mpx
,
sys
,
std
::
move
(
trans
));
}
...
...
libcaf_net/caf/net/middleman.hpp
View file @
2b82a667
...
...
@@ -21,13 +21,14 @@
#include <thread>
#include "caf/actor_system.hpp"
#include "caf/detail/net_export.hpp"
#include "caf/detail/type_list.hpp"
#include "caf/fwd.hpp"
#include "caf/net/fwd.hpp"
namespace
caf
::
net
{
class
middleman
:
public
actor_system
::
module
{
class
CAF_NET_EXPORT
middleman
:
public
actor_system
::
module
{
public:
// -- member types -----------------------------------------------------------
...
...
libcaf_net/caf/net/network_socket.hpp
View file @
2b82a667
...
...
@@ -24,6 +24,7 @@
#include <type_traits>
#include "caf/config.hpp"
#include "caf/detail/net_export.hpp"
#include "caf/fwd.hpp"
#include "caf/net/socket.hpp"
#include "caf/net/socket_id.hpp"
...
...
@@ -31,7 +32,7 @@
namespace
caf
::
net
{
/// A bidirectional network communication endpoint.
struct
network_socket
:
socket
{
struct
CAF_NET_EXPORT
network_socket
:
socket
{
using
super
=
socket
;
using
super
::
super
;
...
...
@@ -39,47 +40,47 @@ struct network_socket : socket {
/// Enables or disables `SIGPIPE` events from `x`.
/// @relates network_socket
error
allow_sigpipe
(
network_socket
x
,
bool
new_value
);
error
CAF_NET_EXPORT
allow_sigpipe
(
network_socket
x
,
bool
new_value
);
/// Enables or disables `SIO_UDP_CONNRESET`error on `x`.
/// @relates network_socket
error
allow_udp_connreset
(
network_socket
x
,
bool
new_value
);
error
CAF_NET_EXPORT
allow_udp_connreset
(
network_socket
x
,
bool
new_value
);
/// Get the socket buffer size for `x`.
/// @pre `x != invalid_socket`
/// @relates network_socket
expected
<
size_t
>
send_buffer_size
(
network_socket
x
);
expected
<
size_t
>
CAF_NET_EXPORT
send_buffer_size
(
network_socket
x
);
/// Set the socket buffer size for `x`.
/// @relates network_socket
error
send_buffer_size
(
network_socket
x
,
size_t
capacity
);
error
CAF_NET_EXPORT
send_buffer_size
(
network_socket
x
,
size_t
capacity
);
/// Returns the locally assigned port of `x`.
/// @relates network_socket
expected
<
uint16_t
>
local_port
(
network_socket
x
);
expected
<
uint16_t
>
CAF_NET_EXPORT
local_port
(
network_socket
x
);
/// Returns the locally assigned address of `x`.
/// @relates network_socket
expected
<
std
::
string
>
local_addr
(
network_socket
x
);
expected
<
std
::
string
>
CAF_NET_EXPORT
local_addr
(
network_socket
x
);
/// Returns the port used by the remote host of `x`.
/// @relates network_socket
expected
<
uint16_t
>
remote_port
(
network_socket
x
);
expected
<
uint16_t
>
CAF_NET_EXPORT
remote_port
(
network_socket
x
);
/// Returns the remote host address of `x`.
/// @relates network_socket
expected
<
std
::
string
>
remote_addr
(
network_socket
x
);
expected
<
std
::
string
>
CAF_NET_EXPORT
remote_addr
(
network_socket
x
);
/// Closes the read channel for a socket.
/// @relates network_socket
void
shutdown_read
(
network_socket
x
);
void
CAF_NET_EXPORT
shutdown_read
(
network_socket
x
);
/// Closes the write channel for a socket.
/// @relates network_socket
void
shutdown_write
(
network_socket
x
);
void
CAF_NET_EXPORT
shutdown_write
(
network_socket
x
);
/// Closes the both read and write channel for a socket.
/// @relates network_socket
void
shutdown
(
network_socket
x
);
void
CAF_NET_EXPORT
shutdown
(
network_socket
x
);
}
// namespace caf::net
libcaf_net/caf/net/packet_writer.hpp
View file @
2b82a667
...
...
@@ -21,13 +21,14 @@
#include <vector>
#include "caf/byte.hpp"
#include "caf/detail/net_export.hpp"
#include "caf/net/fwd.hpp"
#include "caf/span.hpp"
namespace
caf
::
net
{
/// Implements an interface for packet writing in application-layers.
class
packet_writer
{
class
CAF_NET_EXPORT
packet_writer
{
public:
using
buffer_type
=
std
::
vector
<
byte
>
;
...
...
libcaf_net/caf/net/pipe_socket.hpp
View file @
2b82a667
...
...
@@ -22,6 +22,7 @@
#include <system_error>
#include <utility>
#include "caf/detail/net_export.hpp"
#include "caf/fwd.hpp"
#include "caf/net/socket.hpp"
#include "caf/net/socket_id.hpp"
...
...
@@ -29,7 +30,7 @@
namespace
caf
::
net
{
/// A unidirectional communication endpoint for inter-process communication.
struct
pipe_socket
:
socket
{
struct
CAF_NET_EXPORT
pipe_socket
:
socket
{
using
super
=
socket
;
using
super
::
super
;
...
...
@@ -38,7 +39,7 @@ struct pipe_socket : socket {
/// Creates two connected sockets. The first socket is the read handle and the
/// second socket is the write handle.
/// @relates pipe_socket
expected
<
std
::
pair
<
pipe_socket
,
pipe_socket
>>
make_pipe
();
expected
<
std
::
pair
<
pipe_socket
,
pipe_socket
>>
CAF_NET_EXPORT
make_pipe
();
/// Transmits data from `x` to its peer.
/// @param x Connected endpoint.
...
...
@@ -46,7 +47,7 @@ expected<std::pair<pipe_socket, pipe_socket>> make_pipe();
/// @param buf_size Specifies the size of the buffer in bytes.
/// @returns The number of written bytes on success, otherwise an error code.
/// @relates pipe_socket
variant
<
size_t
,
sec
>
write
(
pipe_socket
x
,
span
<
const
byte
>
buf
);
variant
<
size_t
,
sec
>
CAF_NET_EXPORT
write
(
pipe_socket
x
,
span
<
const
byte
>
buf
);
/// Receives data from `x`.
/// @param x Connected endpoint.
...
...
@@ -54,12 +55,12 @@ variant<size_t, sec> write(pipe_socket x, span<const byte> buf);
/// @param buf_size Specifies the maximum size of the buffer in bytes.
/// @returns The number of received bytes on success, otherwise an error code.
/// @relates pipe_socket
variant
<
size_t
,
sec
>
read
(
pipe_socket
x
,
span
<
byte
>
);
variant
<
size_t
,
sec
>
CAF_NET_EXPORT
read
(
pipe_socket
x
,
span
<
byte
>
);
/// Converts the result from I/O operation on a ::pipe_socket to either an
/// error code or a non-zero positive integer.
/// @relates pipe_socket
variant
<
size_t
,
sec
>
check_pipe_socket_io_res
(
std
::
make_signed
<
size_t
>::
type
res
);
CAF_NET_EXPORT
check_pipe_socket_io_res
(
std
::
make_signed
<
size_t
>::
type
res
);
}
// namespace caf::net
libcaf_net/caf/net/receive_policy.hpp
View file @
2b82a667
...
...
@@ -26,7 +26,11 @@
namespace
caf
::
net
{
enum
class
receive_policy_flag
:
unsigned
{
at_least
,
at_most
,
exactly
};
enum
class
CAF_NET_EXPORT
receive_policy_flag
:
unsigned
{
at_least
,
at_most
,
exactly
};
inline
std
::
string
to_string
(
receive_policy_flag
x
)
{
return
x
==
receive_policy_flag
::
at_least
...
...
@@ -34,7 +38,7 @@ inline std::string to_string(receive_policy_flag x) {
:
(
x
==
receive_policy_flag
::
at_most
?
"at_most"
:
"exactly"
);
}
class
receive_policy
{
class
CAF_NET_EXPORT
receive_policy
{
public:
receive_policy
()
=
delete
;
...
...
libcaf_net/caf/net/socket.hpp
View file @
2b82a667
...
...
@@ -24,6 +24,7 @@
#include "caf/config.hpp"
#include "caf/detail/comparable.hpp"
#include "caf/detail/net_export.hpp"
#include "caf/fwd.hpp"
#include "caf/net/socket_id.hpp"
...
...
@@ -31,7 +32,7 @@ namespace caf::net {
/// An internal endpoint for sending or receiving data. Can be either a
/// ::network_socket, ::pipe_socket, ::stream_socket, or ::datagram_socket.
struct
socket
:
detail
::
comparable
<
socket
>
{
struct
CAF_NET_EXPORT
socket
:
detail
::
comparable
<
socket
>
{
socket_id
id
;
constexpr
socket
()
noexcept
:
id
(
invalid_socket_id
)
{
...
...
@@ -54,7 +55,8 @@ struct socket : detail::comparable<socket> {
/// @relates socket
template
<
class
Inspector
>
typename
Inspector
::
result_type
inspect
(
Inspector
&
f
,
socket
&
x
)
{
typename
Inspector
::
result_type
CAF_NET_EXPORT
inspect
(
Inspector
&
f
,
socket
&
x
)
{
return
f
(
x
.
id
);
}
...
...
@@ -63,29 +65,29 @@ constexpr auto invalid_socket = socket{invalid_socket_id};
/// Converts between different socket types.
template
<
class
To
,
class
From
>
To
socket_cast
(
From
x
)
{
To
CAF_NET_EXPORT
socket_cast
(
From
x
)
{
return
To
{
x
.
id
};
}
/// Close socket `x`.
/// @relates socket
void
close
(
socket
x
);
void
CAF_NET_EXPORT
close
(
socket
x
);
/// Returns the last socket error in this thread as an integer.
/// @relates socket
std
::
errc
last_socket_error
();
std
::
errc
CAF_NET_EXPORT
last_socket_error
();
/// Returns the last socket error as human-readable string.
/// @relates socket
std
::
string
last_socket_error_as_string
();
std
::
string
CAF_NET_EXPORT
last_socket_error_as_string
();
/// Sets x to be inherited by child processes if `new_value == true`
/// or not if `new_value == false`. Not implemented on Windows.
/// @relates socket
error
child_process_inherit
(
socket
x
,
bool
new_value
);
error
CAF_NET_EXPORT
child_process_inherit
(
socket
x
,
bool
new_value
);
/// Enables or disables nonblocking I/O on `x`.
/// @relates socket
error
nonblocking
(
socket
x
,
bool
new_value
);
error
CAF_NET_EXPORT
nonblocking
(
socket
x
,
bool
new_value
);
}
// namespace caf::net
libcaf_net/caf/net/stream_socket.hpp
View file @
2b82a667
...
...
@@ -18,6 +18,7 @@
#pragma once
#include "caf/detail/net_export.hpp"
#include "caf/fwd.hpp"
#include "caf/net/network_socket.hpp"
...
...
@@ -25,7 +26,7 @@ namespace caf::net {
/// A connection-oriented network communication endpoint for bidirectional byte
/// streams.
struct
stream_socket
:
network_socket
{
struct
CAF_NET_EXPORT
stream_socket
:
network_socket
{
using
super
=
network_socket
;
using
super
::
super
;
...
...
@@ -34,15 +35,16 @@ struct stream_socket : network_socket {
/// Creates two connected sockets to mimic network communication (usually for
/// testing purposes).
/// @relates stream_socket
expected
<
std
::
pair
<
stream_socket
,
stream_socket
>>
make_stream_socket_pair
();
expected
<
std
::
pair
<
stream_socket
,
stream_socket
>>
CAF_NET_EXPORT
make_stream_socket_pair
();
/// Enables or disables keepalive on `x`.
/// @relates network_socket
error
keepalive
(
stream_socket
x
,
bool
new_value
);
error
CAF_NET_EXPORT
keepalive
(
stream_socket
x
,
bool
new_value
);
/// Enables or disables Nagle's algorithm on `x`.
/// @relates stream_socket
error
nodelay
(
stream_socket
x
,
bool
new_value
);
error
CAF_NET_EXPORT
nodelay
(
stream_socket
x
,
bool
new_value
);
/// Receives data from `x`.
/// @param x Connected endpoint.
...
...
@@ -50,7 +52,7 @@ error nodelay(stream_socket x, bool new_value);
/// @returns The number of received bytes on success, an error code otherwise.
/// @relates stream_socket
/// @post either the result is a `sec` or a positive (non-zero) integer
variant
<
size_t
,
sec
>
read
(
stream_socket
x
,
span
<
byte
>
buf
);
variant
<
size_t
,
sec
>
CAF_NET_EXPORT
read
(
stream_socket
x
,
span
<
byte
>
buf
);
/// Transmits data from `x` to its peer.
/// @param x Connected endpoint.
...
...
@@ -58,7 +60,8 @@ variant<size_t, sec> read(stream_socket x, span<byte> buf);
/// @returns The number of written bytes on success, otherwise an error code.
/// @relates stream_socket
/// @post either the result is a `sec` or a positive (non-zero) integer
variant
<
size_t
,
sec
>
write
(
stream_socket
x
,
span
<
const
byte
>
buf
);
variant
<
size_t
,
sec
>
CAF_NET_EXPORT
write
(
stream_socket
x
,
span
<
const
byte
>
buf
);
/// Transmits data from `x` to its peer.
/// @param x Connected endpoint.
...
...
@@ -68,13 +71,13 @@ variant<size_t, sec> write(stream_socket x, span<const byte> buf);
/// @relates stream_socket
/// @post either the result is a `sec` or a positive (non-zero) integer
/// @pre `bufs.size() < 10`
variant
<
size_t
,
sec
>
write
(
stream_socket
x
,
std
::
initializer_list
<
span
<
const
byte
>>
bufs
);
variant
<
size_t
,
sec
>
CAF_NET_EXPORT
write
(
stream_socket
x
,
std
::
initializer_list
<
span
<
const
byte
>>
bufs
);
/// Converts the result from I/O operation on a ::stream_socket to either an
/// error code or a non-zero positive integer.
/// @relates stream_socket
variant
<
size_t
,
sec
>
check_stream_socket_io_res
(
std
::
make_signed
<
size_t
>::
type
res
);
CAF_NET_EXPORT
check_stream_socket_io_res
(
std
::
make_signed
<
size_t
>::
type
res
);
}
// namespace caf::net
libcaf_net/caf/net/tcp_accept_socket.hpp
View file @
2b82a667
...
...
@@ -18,6 +18,7 @@
#pragma once
#include "caf/detail/net_export.hpp"
#include "caf/fwd.hpp"
#include "caf/net/fwd.hpp"
#include "caf/net/network_socket.hpp"
...
...
@@ -26,7 +27,7 @@
namespace
caf
::
net
{
/// Represents a TCP acceptor in listening mode.
struct
tcp_accept_socket
:
network_socket
{
struct
CAF_NET_EXPORT
tcp_accept_socket
:
network_socket
{
using
super
=
network_socket
;
using
super
::
super
;
...
...
@@ -37,8 +38,8 @@ struct tcp_accept_socket : network_socket {
/// Passing the address `0.0.0.0` will accept incoming connection from any host.
/// Passing port 0 lets the OS choose the port.
/// @relates tcp_accept_socket
expected
<
tcp_accept_socket
>
make_tcp_accept_socket
(
ip_endpoint
node
,
bool
reuse_addr
=
false
);
expected
<
tcp_accept_socket
>
CAF_NET_EXPORT
make_tcp_accept_socket
(
ip_endpoint
node
,
bool
reuse_addr
=
false
);
/// Creates a new TCP socket to accept connections on a given port.
/// @param node The endpoint to listen on and the filter for incoming addresses.
...
...
@@ -47,7 +48,7 @@ expected<tcp_accept_socket> make_tcp_accept_socket(ip_endpoint node,
/// @param reuse_addr Optionally sets the SO_REUSEADDR option on the socket.
/// @relates tcp_accept_socket
expected
<
tcp_accept_socket
>
make_tcp_accept_socket
(
const
uri
::
authority_type
&
node
,
CAF_NET_EXPORT
make_tcp_accept_socket
(
const
uri
::
authority_type
&
node
,
bool
reuse_addr
=
false
);
/// Accepts a connection on `x`.
...
...
@@ -55,6 +56,6 @@ make_tcp_accept_socket(const uri::authority_type& node,
/// @returns The socket that handles the accepted connection on success, an
/// error otherwise.
/// @relates tcp_accept_socket
expected
<
tcp_stream_socket
>
accept
(
tcp_accept_socket
x
);
expected
<
tcp_stream_socket
>
CAF_NET_EXPORT
accept
(
tcp_accept_socket
x
);
}
// namespace caf::net
libcaf_net/caf/net/tcp_stream_socket.hpp
View file @
2b82a667
...
...
@@ -18,6 +18,7 @@
#pragma once
#include "caf/detail/net_export.hpp"
#include "caf/ip_endpoint.hpp"
#include "caf/net/socket.hpp"
#include "caf/net/stream_socket.hpp"
...
...
@@ -26,7 +27,7 @@
namespace
caf
::
net
{
/// Represents a TCP connection.
struct
tcp_stream_socket
:
stream_socket
{
struct
CAF_NET_EXPORT
tcp_stream_socket
:
stream_socket
{
using
super
=
stream_socket
;
using
super
::
super
;
...
...
@@ -36,13 +37,14 @@ struct tcp_stream_socket : stream_socket {
/// @param node Host and port of the remote node.
/// @returns The connected socket or an error.
/// @relates tcp_stream_socket
expected
<
tcp_stream_socket
>
make_connected_tcp_stream_socket
(
ip_endpoint
node
);
expected
<
tcp_stream_socket
>
CAF_NET_EXPORT
make_connected_tcp_stream_socket
(
ip_endpoint
node
);
/// Create a `tcp_stream_socket` connected to `auth`.
/// @param node Host and port of the remote node.
/// @returns The connected socket or an error.
/// @relates tcp_stream_socket
expected
<
tcp_stream_socket
>
expected
<
tcp_stream_socket
>
CAF_NET_EXPORT
make_connected_tcp_stream_socket
(
const
uri
::
authority_type
&
node
);
}
// namespace caf::net
libcaf_net/caf/net/test/host_fixture.hpp
View file @
2b82a667
...
...
@@ -20,12 +20,13 @@
#include <stdexcept>
#include "caf/detail/net_export.hpp"
#include "caf/error.hpp"
#include "caf/net/host.hpp"
namespace
{
struct
host_fixture
{
struct
CAF_NET_EXPORT
host_fixture
{
host_fixture
()
{
if
(
auto
err
=
caf
::
net
::
this_host
::
startup
())
throw
std
::
logic_error
(
"this_host::startup failed"
);
...
...
libcaf_net/caf/net/udp_datagram_socket.hpp
View file @
2b82a667
...
...
@@ -18,6 +18,7 @@
#pragma once
#include "caf/detail/net_export.hpp"
#include "caf/fwd.hpp"
#include "caf/net/network_socket.hpp"
...
...
@@ -25,7 +26,7 @@ namespace caf::net {
/// A datagram-oriented network communication endpoint for bidirectional
/// byte transmission.
struct
udp_datagram_socket
:
network_socket
{
struct
CAF_NET_EXPORT
udp_datagram_socket
:
network_socket
{
using
super
=
network_socket
;
using
super
::
super
;
...
...
@@ -37,12 +38,12 @@ struct udp_datagram_socket : network_socket {
/// port that was bound.
/// @returns The connected socket or an error.
/// @relates udp_datagram_socket
expected
<
std
::
pair
<
udp_datagram_socket
,
uint16_t
>>
expected
<
std
::
pair
<
udp_datagram_socket
,
uint16_t
>>
CAF_NET_EXPORT
make_udp_datagram_socket
(
ip_endpoint
ep
,
bool
reuse_addr
=
false
);
/// Enables or disables `SIO_UDP_CONNRESET` error on `x`.
/// @relates udp_datagram_socket
error
allow_connreset
(
udp_datagram_socket
x
,
bool
new_value
);
error
CAF_NET_EXPORT
allow_connreset
(
udp_datagram_socket
x
,
bool
new_value
);
/// Receives the next datagram on socket `x`.
/// @param x The UDP socket for receiving datagrams.
...
...
@@ -52,8 +53,8 @@ error allow_connreset(udp_datagram_socket x, bool new_value);
/// @relates udp_datagram_socket
/// @post buf was modified and the resulting integer represents the length of
/// the received datagram, even if it did not fit into the given buffer.
variant
<
std
::
pair
<
size_t
,
ip_endpoint
>
,
sec
>
read
(
udp_datagram_socket
x
,
span
<
byte
>
buf
);
variant
<
std
::
pair
<
size_t
,
ip_endpoint
>
,
sec
>
CAF_NET_EXPORT
read
(
udp_datagram_socket
x
,
span
<
byte
>
buf
);
/// Sends the content of `bufs` as a datagram to the endpoint `ep` on socket
/// `x`.
...
...
@@ -64,7 +65,8 @@ variant<std::pair<size_t, ip_endpoint>, sec> read(udp_datagram_socket x,
/// @returns The number of written bytes on success, otherwise an error code.
/// @relates udp_datagram_socket
/// @pre `bufs.size() < 10`
variant
<
size_t
,
sec
>
write
(
udp_datagram_socket
x
,
span
<
std
::
vector
<
byte
>*>
bufs
,
variant
<
size_t
,
sec
>
CAF_NET_EXPORT
write
(
udp_datagram_socket
x
,
span
<
std
::
vector
<
byte
>*>
bufs
,
ip_endpoint
ep
);
/// Sends the content of `buf` as a datagram to the endpoint `ep` on socket `x`.
...
...
@@ -73,13 +75,13 @@ variant<size_t, sec> write(udp_datagram_socket x, span<std::vector<byte>*> bufs,
/// @param ep The enpoint to send the datagram to.
/// @returns The number of written bytes on success, otherwise an error code.
/// @relates udp_datagram_socket
variant
<
size_t
,
sec
>
write
(
udp_datagram_socket
x
,
span
<
const
byte
>
buf
,
ip_endpoint
ep
);
variant
<
size_t
,
sec
>
CAF_NET_EXPORT
write
(
udp_datagram_socket
x
,
span
<
const
byte
>
buf
,
ip_endpoint
ep
);
/// Converts the result from I/O operation on a ::udp_datagram_socket to either
/// an error code or a non-zero positive integer.
/// @relates udp_datagram_socket
variant
<
size_t
,
sec
>
variant
<
size_t
,
sec
>
CAF_NET_EXPORT
check_udp_datagram_socket_io_res
(
std
::
make_signed
<
size_t
>::
type
res
);
}
// namespace caf::net
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