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

  • Home
  • SEARCH
  • 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 6961127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:29:27+00:00 2026-05-27T15:29:27+00:00

I would like to know the proper way to handle a new connection from

  • 0

I would like to know the proper way to handle a new connection from a client using AcceptEx and OpenSSL. I have a perfectly good working server that uses AcceptEx with IO Completion Ports over regular HTTP. I would like to add OpenSSL support to it.

I have read several articles on the internet about using OpenSSL with non blocking sockets:

  • IO Completion Ports and OpenSSL
  • http://zzz.zggg.com/2007/12/22/ssl-server-with-openssl-memory-bio-a-k-a-prerequisite-to-asynchronous-openssl/
  • http://marc.info/?l=openssl-users&m=99909952822335&w=2
  • http://www.lenholgate.com/blog/2002/11/using-openssl-with-asynchronous-sockets.html

None of them seem to touch on how to do this because they are mostly concerned with the client side of the connection. AcceptEx establishes the socket connection AND returns you the first piece of data sent from the client. The first link I posted discusses how you should handle incoming data with IOCP. I have tried what is posted there without any luck so far. Basically what I’m seeing on my server is the following:

  1. The accepted connection completion is received.
  2. I create the SSL object with SSL_new(ctx)
  3. I create the in and out BIO objects with BIO_new(BIO_s_mem()).
  4. I set the BIOs in the SSL object by calling SSL_set_bio(ssl, bioIn, bioOut).
  5. I call SSL_set_accept_state(ssl) to allow SSL_read and SSL_write to do negotiations.

I then proceed to trying to deal with the first buffer of data that was read by the AcceptEx call.

  1. I call BIO_Write(bioIn, buf, len) to copy the read data into SSL.
  2. I then check for pending handshake data on bioOut to see if that needs to be sent back to the client. When accepting a new connection I have never seen there be any data in bioOut at this point though.
  3. I then call SSL_read(ssl, plainTextBuf, len) to try to decrypt the data that I put into bioIn during step 6. This always returns -1, and SSL_get_error returns ERROR_SSL_WANT_READ. As I understand it, this means that bioIn doesn’t have a full SSL record, so SSL needs more data from the client before it can decrypt anything.

Here is where I start to run into problems, and its where I think I need some direction. I have tried a number of things. If I repeatedly call SSL_read at this point, it will infinitely return ERROR_SSL_WANT_READ, presumably because using a memory BIO doesn’t actually communicate over the socket to receive any more data. Should I post a WSARecv call to await more data from the client?

I have also tried checking the bioOut buffer using BIO_read at this point to see if there is data I need to send back to the client. Indeed there is some, and I send this back using WSASend as well as posting another WSARecv call to wait for more data (in response to my send). This results in receiving some more data from the client (the WSARecv completes after the send goes through), so it appears as if the connection is progressing. However, when I handle this completed read, both SSL_read and BIO_read return ERROR_SSL_WANT_READ. So, I don’t have enough data to decrypt a full record, and there is nothing for me to send back to the client. Posting another WSARecv call in response to this situation does not receive any more data from the client either. I don’t know what SSL wants here.

I’m stuck right now, but I’ll keep trying more things. I will update this question with comments if I figure anything out.

  • 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-05-27T15:29:28+00:00Added an answer on May 27, 2026 at 3:29 pm

    You issue a new overlapped read on the socket, wait for that to complete, push the data into your BIO and loop around through the steps that you’re currently doing again.

    ERROR_SSL_WANT_READ means that the BIO needs more data, i.e. it wants another read.

    At any point during your data flow you may need to allow the SSL layer to send or receive more data before you can push more application level data into the BIO.

    I thought I covered all of this pretty clearly in the article that you reference; and the code in that article was the basis for the code that I use in my own IOCP based servers…

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

Sidebar

Related Questions

I'm designing a REST API, and I would like to know the proper way
I would like to know how. I have looked at this topic , and
I am using Ruby on Rails 3.2.2 and I would like to know if
I would like to know what the reasoning could be for inconsistent way sql
I would like to know the best approach of publishing .NET applications using Oracle.DataAccess.
i would like know some reference. I know i can googling it. but prefer
Would like to know what a programmer should know to become a good at
Would like to know the c# code to actually retrieve the IP type: Static
Would like to know how to integarate cruise control with maven? Cruise Control comes
Would like to know how to hide an div after a set of css3

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.