Branch data Line data Source code
1 : : /*
2 : : * Copyright 2025 Jinwoo Sung
3 : : *
4 : : * Licensed under the Apache License, Version 2.0 (the "License");
5 : : * you may not use this file except in compliance with the License.
6 : : * You may obtain a copy of the License at
7 : : *
8 : : * http://www.apache.org/licenses/LICENSE-2.0
9 : : *
10 : : * Unless required by applicable law or agreed to in writing, software
11 : : * distributed under the License is distributed on an "AS IS" BASIS,
12 : : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 : : * See the License for the specific language governing permissions and
14 : : * limitations under the License.
15 : : */
16 : :
17 : : #include "wirestead/transport/uds/boost_uds_socket.hpp"
18 : :
19 : : namespace wirestead {
20 : : namespace transport {
21 : :
22 : : namespace net = boost::asio;
23 : : using uds = net::local::stream_protocol;
24 : :
25 : 41 : BoostUdsSocket::BoostUdsSocket(uds::socket sock) : socket_(std::move(sock)) {}
26 : :
27 : 69 : void BoostUdsSocket::async_read_some(const net::mutable_buffer& buffer,
28 : : std::function<void(const boost::system::error_code&, std::size_t)> handler) {
29 : 69 : socket_.async_read_some(buffer, std::move(handler));
30 : 69 : }
31 : :
32 : 0 : void BoostUdsSocket::async_write(const net::const_buffer& buffer,
33 : : std::function<void(const boost::system::error_code&, std::size_t)> handler) {
34 : 0 : net::async_write(socket_, buffer, std::move(handler));
35 : 0 : }
36 : :
37 : 17 : void BoostUdsSocket::async_connect(const uds::endpoint& endpoint,
38 : : std::function<void(const boost::system::error_code&)> handler) {
39 : 17 : socket_.async_connect(endpoint, std::move(handler));
40 : 17 : }
41 : :
42 : 0 : void BoostUdsSocket::shutdown(uds::socket::shutdown_type what, boost::system::error_code& ec) {
43 : 0 : socket_.shutdown(what, ec);
44 : 0 : }
45 : :
46 : 54 : void BoostUdsSocket::close(boost::system::error_code& ec) { socket_.close(ec); }
47 : :
48 : 0 : uds::endpoint BoostUdsSocket::remote_endpoint(boost::system::error_code& ec) const {
49 : 0 : return socket_.remote_endpoint(ec);
50 : : }
51 : :
52 : : } // namespace transport
53 : : } // namespace wirestead
|