X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=src%2Ftype3_AndroidCloud%2Fanbox-master%2Fsrc%2Fanbox%2Fnetwork%2Fbase_socket_messenger.h;fp=src%2Ftype3_AndroidCloud%2Fanbox-master%2Fsrc%2Fanbox%2Fnetwork%2Fbase_socket_messenger.h;h=d147fcabe0517f402b1e3e3e10c444cb4cd7181c;hb=e26c1ec581be598521517829adba8c8dd23a768f;hp=0000000000000000000000000000000000000000;hpb=6699c1aea74eeb0eb400e6299079f0c7576f716f;p=iec.git diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/network/base_socket_messenger.h b/src/type3_AndroidCloud/anbox-master/src/anbox/network/base_socket_messenger.h new file mode 100644 index 0000000..d147fca --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/network/base_socket_messenger.h @@ -0,0 +1,65 @@ +/* + * Copyright © 2013-2014 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Authored by: Kevin DuBois + */ + +#ifndef ANBOX_NETWORK_BASE_SOCKET_MESSENGER_H_ +#define ANBOX_NETWORK_BASE_SOCKET_MESSENGER_H_ + +#include "anbox/common/fd_sets.h" +#include "anbox/network/socket_messenger.h" + +#include +#include + +namespace anbox { +namespace network { +template +class BaseSocketMessenger : public SocketMessenger { + public: + BaseSocketMessenger( + std::shared_ptr> const& + socket); + virtual ~BaseSocketMessenger(); + + Credentials creds() const override; + unsigned short local_port() const override; + + void send(char const* data, size_t length) override; + ssize_t send_raw(char const* data, size_t length) override; + void async_receive_msg(AnboxReadHandler const& handle, + boost::asio::mutable_buffers_1 const& buffer) override; + boost::system::error_code receive_msg( + boost::asio::mutable_buffers_1 const& buffer) override; + size_t available_bytes() override; + + void set_no_delay() override; + void close() override; + + protected: + BaseSocketMessenger(); + void setup(std::shared_ptr< + boost::asio::basic_stream_socket> const& s); + + private: + std::shared_ptr> socket; + anbox::Fd socket_fd; + std::mutex message_lock; +}; +} // namespace network +} // namespace anbox + +#endif