4 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
28 #include "event_loop.h"
29 #include "channel_handler.h"
33 class channel_handler;
37 /* move owernership of the socket to the channel */
38 channel(socket *sock);
42 uint64_t bind(channel_handler *handler, event_loop *loop, bool loop_bind);
44 uint64_t connect(channel_handler *handler, event_loop *loop, bool loop_bind);
45 void disconnect(void);
47 bool is_connected(void);
49 bool send(message *msg);
50 bool send_sync(message *msg);
53 bool read_sync(message &msg, bool select = true);
55 bool get_option(int type, int &value) const;
56 bool set_option(int type, int value);
58 int get_fd(void) const;
64 channel_handler *m_handler;
67 std::atomic<bool> m_connected;
72 #endif /* __CHANNEL_H__ */