forked from scylladb/seastar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstack.cc
119 lines (92 loc) · 3.09 KB
/
stack.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
* This file is open source software, licensed to you under the terms
* of the Apache License, Version 2.0 (the "License"). See the NOTICE file
* distributed with this work for additional information regarding copyright
* ownership. You may not use this file except in compliance with the License.
*
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/*
* Copyright 2015 Cloudius Systems
*/
#include "stack.hh"
#include "core/reactor.hh"
net::udp_channel::udp_channel()
{}
net::udp_channel::udp_channel(std::unique_ptr<udp_channel_impl> impl) : _impl(std::move(impl))
{}
net::udp_channel::~udp_channel()
{}
net::udp_channel::udp_channel(udp_channel&&) = default;
net::udp_channel& net::udp_channel::operator=(udp_channel&&) = default;
future<net::udp_datagram> net::udp_channel::receive() {
return _impl->receive();
}
future<> net::udp_channel::send(ipv4_addr dst, const char* msg) {
return _impl->send(std::move(dst), msg);
}
future<> net::udp_channel::send(ipv4_addr dst, packet p) {
return _impl->send(std::move(dst), std::move(p));
}
bool net::udp_channel::is_closed() const {
return _impl->is_closed();
}
void net::udp_channel::close() {
return _impl->close();
}
connected_socket::connected_socket()
{}
connected_socket::connected_socket(
std::unique_ptr<net::connected_socket_impl> csi)
: _csi(std::move(csi)) {
}
connected_socket::connected_socket(connected_socket&& cs) noexcept = default;
connected_socket& connected_socket::operator=(connected_socket&& cs) noexcept = default;
connected_socket::~connected_socket()
{}
input_stream<char> connected_socket::input() {
return input_stream<char>(_csi->source());
}
output_stream<char> connected_socket::output() {
// TODO: allow user to determine buffer size etc
return output_stream<char>(_csi->sink(), 8192, false, true);
}
void connected_socket::set_nodelay(bool nodelay) {
_csi->set_nodelay(nodelay);
}
bool connected_socket::get_nodelay() const {
return _csi->get_nodelay();
}
future<> connected_socket::shutdown_output() {
return _csi->shutdown_output();
}
future<> connected_socket::shutdown_input() {
return _csi->shutdown_input();
}
server_socket::server_socket() {
}
server_socket::server_socket(std::unique_ptr<net::server_socket_impl> ssi)
: _ssi(std::move(ssi)) {
}
server_socket::server_socket(server_socket&& ss) noexcept = default;
server_socket& server_socket::operator=(server_socket&& cs) noexcept = default;
server_socket::~server_socket() {
}
future<connected_socket, socket_address> server_socket::accept() {
return _ssi->accept();
}
void server_socket::abort_accept() {
_ssi->abort_accept();
}
socket_address::socket_address(ipv4_addr addr)
: socket_address(make_ipv4_address(addr))
{}