0
from BaseHTTPServer import HTTPServer
from CGIHTTPServer  import CGIHTTPRequestHandler
import socket,ssl
import time
import Config

class StartHTTPServer:
    '''Web server to serve out map image and provide cgi'''


    def __init__(self):
        # Start HTTP Server. Port and address defined in Config.py
        srvraddr = ("", Config.HTTP_PORT)                     # my hostname, portnumber
        srvrobj  = HTTPServer(srvraddr, CGIHTTPRequestHandler)

        srvrobj.socket = ssl.wrap_socket(srvrobj.socket,server_side=True,
                                    certfile="c:\users\shuen\desktop\servertryout 23022012\serverCert.crt",
                                    keyfile="c:\users\shuen\desktop\servertryout 23022012\privateKey.key",
                                    ssl_version=ssl.PROTOCOL_TLSv1,
                                    do_handshake_on_connect=True)

        print srvrobj.socket.cipher() 
        print srvrobj.socket.getsockname()
        print "HTTP server running at IP Address %s port %s." % (Config.HTTP_ADDRESS, Config.HTTP_PORT)
        srvrobj.serve_forever()                              # run as perpetual demon

        srvrobj.socket.accept()
        message='hello from server.<EOF>'
        srvrobj.socket.send(message)

I have tried to send data with a normal socket, which works. However, the code i'm working on is using socketServer and can't be change. I cannot find any example which will send data across to the server. How can I do that?

orlp
  • 112,504
  • 36
  • 218
  • 315
Shuen
  • 35
  • 5

1 Answers1

0

If you really cannot change your server software, you must use a wrapper, e. g. openssl s_server.

glglgl
  • 89,107
  • 13
  • 149
  • 217
  • I'm wondering whether SocketServer can send out message to a socket, after the command serve_forever? Not sure whether i would need a wrapper. – Shuen Mar 05 '12 at 09:08