2 * Copyright © 2014 Canonical Ltd.
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
19 #ifndef ANBOX_NETWORK_FD_SOCKET_TRANSMISSION_H_
20 #define ANBOX_NETWORK_FD_SOCKET_TRANSMISSION_H_
22 #include "anbox/common/fd.h"
25 #include <system_error>
29 struct socket_error : std::system_error {
30 socket_error(std::string const& message);
33 struct socket_disconnected_error : std::system_error {
34 socket_disconnected_error(std::string const& message);
37 struct fd_reception_error : std::runtime_error {
38 fd_reception_error(std::string const& message);
41 bool socket_error_is_transient(int error_code);
42 void send_fds(Fd const& socket, std::vector<Fd> const& fd);
43 void receive_data(Fd const& socket, void* buffer, size_t bytes_requested,
44 std::vector<Fd>& fds);