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 4000232
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:45:22+00:00 2026-05-20T07:45:22+00:00

I have a socket server that I am trying to move over to SSL

  • 0

I have a socket server that I am trying to move over to SSL on python 2.5, but I’ve run into a snag with pyOpenSSL. I can’t find any good tutorials on using it, so I’m operating largely on guesses.

Here is how my server sets up the socket:

ctx = SSL.Context(SSL.SSLv23_METHOD)
ctx.use_privatekey_file ("mykey.pem")
ctx.use_certificate_file("mycert.pem")
sock = SSL.Connection(ctx, socket.socket(socket.AF_INET, socket.SOCK_STREAM))
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
addr = ('', int(8081))
sock.bind(addr)
sock.listen(5)

Here is how it accepts clients:

sock.setblocking(0)
while True:
  if len(select([sock], [], [], 0.25)[0]):
    client_sock, client_addr = sock.accept()
    client = ClientGen(client_sock)

And here is how it sends/receives from the connected sockets:

while True:
  (r, w, e) = select.select([sock], [sock], [], 0.25)

  if len(r):
    bytes = sock.recv(1024)
  if len(w):
    n_bytes = sock.send(self.message)

It’s compacted, but you get the general idea. The problem is, once the send/receive loop starts, it dies right away, before anything has been sent or received (that I can see anyway):

Traceback (most recent call last):
  File "ClientGen.py", line 50, in networkLoop
    n_bytes = sock.send(self.message
WantReadError

The manual’s description of the ‘WantReadError’ is very vague, saying it can come from just about anywhere. What am I doing wrong?

  • 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-20T07:45:23+00:00Added an answer on May 20, 2026 at 7:45 am

    Sometimes in order to send application bytes of an SSL connection, you need to be able to read more bytes from the connection first. WantReadError is how this case is indicated. The only thing you’re doing wrong is that you’re not handling the WantReadError and then waiting until select indicates that the socket is readable before you try calling send again.

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

Sidebar

Related Questions

I am trying to adapt my simple socket server so that it can have
I am trying to make a socket server that spews mouse move events, in
I'm trying to build a AS3 socket server that can handshake with html5 websockets.
I'm trying to set up a very simple UDP socket server with python that
Background I have a simple socket server setup that I am trying to allow
I currently have a small socket server that I'm trying to convert to a
I have a server that sends data via a socket, the data is a
I have a server that listens for a connection on a socket: public class
I have to create an sample code that connect to a socket server, and
I have a class that encapsulates tcp socket communications with a server. For each

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.