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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:19:34+00:00 2026-06-11T11:19:34+00:00

I am trying to get a prototype ready and am having trouble getting a

  • 0

I am trying to get a prototype ready and am having trouble getting a connection. I’m using OpenSSL for both the client and the server.

#!/usr/bin/env python

import SocketServer
import json
from OpenSSL import SSL
import os
import socket

TERMINATION_STRING = "Done"

CERTIFICATE_PATH = os.getcwd() + '/CA/certs/01.pem'
KEY_PATH = os.getcwd() + '/CA/private/key.pem'

class SSLThreadingTCPServer(SocketServer.ThreadingTCPServer):
    def __init__(self, address, handler):
        SocketServer.ThreadingTCPServer.__init__(self, address, handler)

        ctx = SSL.Context(SSL.SSLv23_METHOD)

        #ctx.use_privatekey_file(KEY_PATH)
        #ctx.use_certificate_file(CERTIFICATE_PATH)
        self.socket = SSL.Connection(ctx, socket.socket(self.address_family, self.socket_type))

        print "Serving:", address[0], "on port:", address[1]



class MemberUpdateHandler(SocketServer.BaseRequestHandler):
    def setup(self):
        print self.client_address, "connected"

    def handle(self):
        data = ""
        while True:
            data += self.request.recv(1024).encode('utf-8').strip
            if data[-4:] == "Done":
                print "Done"
                break

            dataStrings = data.split(' ')
            for item in dataStrings:
                print item
if __name__ == "__main__":
    ADDRESS = 'localhost'
    PORT = 42424
    HOST = (ADDRESS, PORT)

    s = SSLThreadingTCPServer(HOST, MemberUpdateHandler)
    s.serve_forever()

And the client:

#!/usr/bin/env python

from OpenSSL import SSL
import socket
import os

HOST = 'localhost'
PORT = 42424
ADDRESS = (HOST, PORT)

CERTIFICATE_FILE = os.getcwd() + '/CA/certs/02.pem'

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

ctx = SSL.Context(SSL.SSLv23_METHOD)
sslSock = SSL.Connection(ctx, sock)
sslSock.connect(ADDRESS) #THIS IS WHERE IT FAILS

items = "this is a test Done"

sslSock.sendall(items)

sslSock.close()

Finally, the error:

File "SSLClient.py", line 19, in <module> sslSock.connect(ADDRESS)
File "<string>", line 1, in connect
socket.error: [Errno 111] Connection refused

Any help would be appreciated. I get the feeling I’m missing something simple, but I am new to network programming.

netstat -tpn output while the server is running:

(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)

Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 198.183.6.199:59724     74.125.227.0:80         ESTABLISHED 2128/google-chrome
tcp        0      0 198.183.6.199:49758     74.125.227.16:80        ESTABLISHED 2128/google-chrome
tcp        0      0 198.183.6.199:39299     69.30.156.16:443        ESTABLISHED 2128/google-chrome
tcp        0      0 198.183.6.199:44128     23.0.38.218:80          TIME_WAIT   -
tcp        0      0 198.183.6.199:41272     64.34.119.101:80        ESTABLISHED 2128/google-chrome
tcp        0      0 198.183.6.199:39420     69.30.156.26:443        ESTABLISHED 2128/google-chrome
tcp        0      0 198.183.6.199:39418     69.30.156.26:443        ESTABLISHED 2128/google-chrome
tcp        0      0 198.183.6.199:41218     64.34.119.101:80        ESTABLISHED 2128/google-chrome
tcp        0      0 198.183.6.199:56224     198.183.6.22:22         ESTABLISHED 3156/ssh
tcp        0      0 198.183.6.199:54281     74.125.227.10:443       ESTABLISHED 2128/google-chrome
tcp        0      0 198.183.6.199:46349     69.30.156.11:443        ESTABLISHED 2128/google-chrome
tcp        0      0 198.183.6.199:54380     74.125.227.62:443       ESTABLISHED 2128/google-chrome
tcp        0      0 198.183.6.199:42252     75.126.125.212:80       ESTABLISHED 2128/google-chrome
tcp        0      0 198.183.6.199:39300     69.30.156.16:443        ESTABLISHED 2128/google-chrome
tcp        0      0 198.183.6.199:53321     74.125.227.15:443       ESTABLISHED 2128/google-chrome
tcp        0      0 198.183.6.199:60669     74.125.227.0:80         ESTABLISHED 2128/google-chrome
tcp        0      0 198.183.6.199:54285     74.125.227.10:443       ESTABLISHED 2128/google-chrome
tcp        0      0 198.183.6.199:37783     74.125.137.125:5222     ESTABLISHED 2128/google-chrome
tcp        0      0 198.183.6.199:897       198.183.6.22:2049       ESTABLISHED -
tcp        0      0 198.183.6.199:45040     69.171.248.16:443       ESTABLISHED 2128/google-chrome
tcp        0      0 198.183.6.199:54286     74.125.227.10:443       ESTABLISHED 2128/google-chrome
tcp        0      0 198.183.6.199:54284     74.125.227.10:443       ESTABLISHED 2128/google-chrome
tcp        0      0 198.183.6.199:38499     74.125.227.21:443       ESTABLISHED 2128/google-chrome
tcp        0      0 198.183.6.199:54157     173.194.33.47:443       ESTABLISHED 2128/google-chrome
tcp        0      0 198.183.6.199:44312     70.84.101.150:6667      ESTABLISHED 5776/xchat
tcp        0      0 198.183.6.199:46074     69.30.156.32:80         ESTABLISHED 2128/google-chrome
tcp        0      0 198.183.6.199:39298     69.30.156.16:443        ESTABLISHED 2128/google-chrome
tcp        0      0 198.183.6.199:58444     74.125.227.16:443       ESTABLISHED 2128/google-chrome
tcp        0      0 198.183.6.199:39056     198.183.6.100:993       ESTABLISHED 3180/thunderbird-bi
tcp        0      0 198.183.6.199:54283     74.125.227.10:443       ESTABLISHED 2128/google-chrome
tcp        0      0 198.183.6.199:54910     173.194.64.116:80       ESTABLISHED 2128/google-chrome
tcp        0      0 198.183.6.199:10050     198.183.6.231:34955     TIME_WAIT   -
tcp        0      0 198.183.6.199:56503     72.247.172.20:80        ESTABLISHED 2128/google-chrome
tcp        0      0 198.183.6.199:52454     173.194.64.95:443       ESTABLISHED 2128/google-chrome
tcp        0      0 198.183.6.199:968       198.183.6.11:2049       ESTABLISHED -
tcp        0      0 198.183.6.199:39419     69.30.156.26:443        ESTABLISHED 2128/google-chrome
tcp        0      0 198.183.6.199:52088     74.125.227.0:443        ESTABLISHED 2128/google-chrome
tcp        0      0 198.183.6.199:33184     198.183.6.1:6667        ESTABLISHED 5776/xchat
tcp        0      0 198.183.6.199:39417     69.30.156.26:443        ESTABLISHED 2128/google-chrome
  • 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-11T11:19:36+00:00Added an answer on June 11, 2026 at 11:19 am

    When you call

    SocketServer.ThreadingTCPServer.__init__(self, address, handler)

    in your subclass, the ThreadingTCPServer will create a socket and do the bind/listen. After that line you do

    self.socket = SSL.Connection(ctx, socket.socket(self.address_family, self.socket_type))
    

    to create your SSL socket. This socket does not get bound though. What you need to do is call the super class’ constructor differently:

    SocketServer.ThreadingTCPServer.__init__(self, address, handler, bind_and_activate=False)

    Note the last argument. This will prevent the superclass from binding the socket that it creates. Then, after you create your socket, call self.server_bind() and self.server_activate() so that the socket you created is properly setup.

    In summary, try changing your server to:

    class SSLThreadingTCPServer(SocketServer.ThreadingTCPServer):
        def __init__(self, address, handler):
            SocketServer.ThreadingTCPServer.__init__(self, address, handler, bind_and_activate=False)
    
            ctx = SSL.Context(SSL.SSLv23_METHOD)
    
            #ctx.use_privatekey_file(KEY_PATH)
            #ctx.use_certificate_file(CERTIFICATE_PATH)
            self.socket = SSL.Connection(ctx, socket.socket(self.address_family, self.socket_type))
            self.server_bind()
            self.server_activate()
    
    
            print "Serving:", address[0], "on port:", address[1]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get a simple prototype using ASP.NET S#arp-architecture (Sharp architecture) to
I am using http://nurey.com/corners.html with Prototype framework and trying to get some rounded corner
I'm using prototype and trying to get the filename and extension out of a
I'm trying to get some RJS code written with prototype and Rails 2.3.11 to
So i am trying get 2 div-containers which both should contain centered text (Both
I am trying get all html links within a string and replace them using
I am trying get all html links within a string and replace them using
I am trying get Struts 2 and Tiles to work and I am using
I am currently trying to get into writing proper C++ code (getting it running
I'm trying to get Ben Keen's RSV for Prototype working. I found a suggestion

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.