diff --git a/bakanet/src/bakanet/sock_layer/socket.h b/bakanet/src/bakanet/sock_layer/socket.h index eeedc78..56057dc 100755 --- a/bakanet/src/bakanet/sock_layer/socket.h +++ b/bakanet/src/bakanet/sock_layer/socket.h @@ -17,11 +17,21 @@ namespace Bk::Net { virtual bool start(int cpt_conn) = 0; virtual Connection ack() = 0; virtual bool conn() = 0; + + virtual int get_raw_socket() = 0; + virtual void emit(std::vector packet) = 0; virtual void emit(Connection socket, std::vector packet) = 0; virtual std::vector obtain(int size) = 0; virtual std::vector obtain(Connection socket, int size) = 0; - - static std::unique_ptr Create(IpAddress ip, int port, IpProtocol proto); + + template + static bool set_option(Socket& socket, int level, int option_name, const T* option_value) + { + int status = setsockopt(socket.get_raw_socket(), level, option_name, (void*)option_value, sizeof(T)); + log(status) + return status == 0 ? true : false; + } + static std::unique_ptr create(IpAddress ip, int port, IpProtocol proto); }; } \ No newline at end of file diff --git a/bakanet/src/bakanet/sock_layer/socket_options.h b/bakanet/src/bakanet/sock_layer/socket_options.h new file mode 100644 index 0000000..e69de29