TYPE3
[iec.git] / src / type3_AndroidCloud / anbox-master / src / anbox / network / fd_socket_transmission.h
1 /*
2  * Copyright © 2014 Canonical Ltd.
3  *
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.
7  *
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.
12  *
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/>.
15  *
16  * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
17  */
18
19 #ifndef ANBOX_NETWORK_FD_SOCKET_TRANSMISSION_H_
20 #define ANBOX_NETWORK_FD_SOCKET_TRANSMISSION_H_
21
22 #include "anbox/common/fd.h"
23
24 #include <stdexcept>
25 #include <system_error>
26 #include <vector>
27
28 namespace anbox {
29 struct socket_error : std::system_error {
30   socket_error(std::string const& message);
31 };
32
33 struct socket_disconnected_error : std::system_error {
34   socket_disconnected_error(std::string const& message);
35 };
36
37 struct fd_reception_error : std::runtime_error {
38   fd_reception_error(std::string const& message);
39 };
40
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);
45 }
46
47 #endif