Search code examples
c++websocketboost-asiowebsocket++

Get the native socket descriptor from the connection or connection_ptr in websocketpp?


Is there any way to get the native socket descriptor from the connection or connection_ptr in websocketpp? I need to set the TCP_CORK before I send the frame to the client. I am new to Boost.Asio please advise.


Solution

  • From following the github code, you can likely call connection_ptr->get_raw_socket().native_handle().

    websocketpp::connection inherits from websocketpp::socket::connection, and websocket::socket::connection provides a get_socket() public member function that returns a reference to a Boost.Asio socket. Boost.Asio sockets provide a native_handle() member function that returns the native socket representation.