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.
24 #include <sys/types.h>
25 #include <sys/socket.h>
35 socket(const socket &sock);
38 virtual bool create(const std::string &path);
42 bool listen(const int max_connections);
43 bool accept(socket &client_sock);
47 int get_fd(void) const;
48 void set_fd(int sock_fd);
50 int get_mode(void) const;
51 bool set_mode(int mode);
53 bool set_blocking_mode(bool blocking);
54 bool set_recv_timeout(int timeout);
56 /* type : SO_SNDBUF, SO_RCVBUF */
57 bool set_buffer_size(int type, int size);
58 int get_buffer_size(int type);
59 int get_current_buffer_size(void);
61 ssize_t send(const void *buffer, size_t size, bool select = false) const;
62 ssize_t recv(void* buffer, size_t size, bool select = false) const;
65 bool create_by_type(const std::string &path, int type);
68 virtual ssize_t on_send(const void *buffer, size_t size) const = 0;
69 virtual ssize_t on_recv(void* buffer, size_t size) const = 0;
71 int get_sock_type(void);
72 bool set_sock_type(int type);
73 bool has_connected(void);
77 std::atomic<bool> m_listening;
83 #endif /* __SOCKET_H__ */