Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8916739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:19:10+00:00 2026-06-15T05:19:10+00:00

I have these typedefs the problem is I need pass a secure socket as

  • 0

I have these typedefs the problem is I need pass a secure socket as TSocket will a direct cast from TSecureSocket to TSocket work ? or is there another solution? depending on the port I will make the socket secure and in others I will not. I just need the return type to be TSocket.

  typedef boost::asio::ip::tcp::socket            TBoostSocket;
  typedef boost::asio::ssl::stream<TBoostSocket>  TSLLSocket;
  typedef boost::shared_ptr<TBoostSocket>         TSocket;
  typedef boost::shared_ptr<TSLLSocket>           TSecureSocket;

I have looked at this
boost::asio convert socket to secure

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:19:11+00:00Added an answer on June 15, 2026 at 5:19 am

    I have these typedefs

      typedef boost::asio::ip::tcp::socket            TBoostSocket;
      typedef boost::asio::ssl::stream<TBoostSocket>  TSLLSocket;
      typedef boost::shared_ptr<TBoostSocket>         TSocket;
      typedef boost::shared_ptr<TSLLSocket>           TSecureSocket;
    

    the problem is I need pass a secure socket as TSocket. Will a direct
    cast from TSecureSocket to TSocket work ?

    Short Answer No. Because boost::asio::ssl::stream<TBoostSocket> wraps the socket.

    or is there another solution? depending on the port I will make the
    socket secure and in others I will not I just need the return type to
    be TSocket.

    However TSLLSocket (or boost::asio::ssl::stream rather) provides a method for retrieving the socket from an instance:

    const next_layer_type & next_layer() const;
    

    http://www.boost.org/doc/libs/1_52_0/doc/html/boost_asio/reference/ssl__stream/next_layer/overload1.html

    Where next_layer_type is defined by the following typedef:

    typedef boost::remove_reference< Stream >::type next_layer_type;
    

    http://www.boost.org/doc/libs/1_52_0/doc/html/boost_asio/reference/ssl__stream/next_layer_type.html

    Since you define your template with TBoostSocket that is what you should get when you call next_layer() or lowest_layer()

    Of course this returns a reference not a pointer, and that reference is to an instance not owned by you. So you will now need to somehow wrap this in a shared_ptr, and that may not be that easy since you can’t allow it to be deleted.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a header file in where I store various typedefs. The problem is
I have these structs: typedef struct _Frag{ struct _Frag *next; char *seq; int x1;
I have these 3 tables: and I'm using this code to join them together
I have these three lists with the same number of elements List<String>competitoinsIDs = new
I have these tables: comments uid id pid pages pid user users id rank
I have these variables: boost::regex re //regular expression to use std::string stringToChange //replace this
I have these tables places(place_id, place_name) places_criteria(place_id, criterion_id) criteria(criterion_id, criterion_name) places_criteria have foreign keys
I have these simplified types: public class DataBean extends ZZZZZ { public String name;
I have these tables: Idea and poll (and others) which are types of what
I have these codes for my two tabs. I would like to change the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.