SocketServer.ThreadingTCPServer accepts clients outside server_forever

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Okko Willeboordse

    SocketServer.ThreadingTCPServer accepts clients outside server_forever

    Hello,

    SocketServer.Th readingTCPServe r accepts connections (clients can
    connect) before and after it's server_forever method is called,
    see below for an example.

    IMHO it should only accept connections while server_forever is
    running.

    Kind regards,

    Okko

    Example, both _socket.connect calls should throw;

    import SocketServer
    import threading
    import time
    import socket

    server = SocketServer.Th readingTCPServe r(("127.0.0.1" , 12345),
    SocketServer.Ba seRequestHandle r)

    _socket = socket.socket(s ocket.AF_INET, socket.SOCK_STR EAM)

    _socket.connect (("127.0.0.1" , 12345))

    def shutdown_server ():
    while not server._BaseSer ver__serving:
    time.sleep(0.1)
    server.shutdown ()

    thread = threading.Threa d(target = shutdown_server )
    thread.start()

    server.serve_fo rever()
    thread.join()

    _socket = socket.socket(s ocket.AF_INET, socket.SOCK_STR EAM)

    _socket.connect (("127.0.0.1" , 12345))
  • Mark Tolonen

    #2
    Re: SocketServer.Th readingTCPServe r accepts clients outside server_forever


    "Okko Willeboordse" <trash@willeboo rdse.demon.nlwr ote in message
    news:491745d6$0 $3485$e4fe514c@ dreader19.news. xs4all.nl...
    Hello,
    >
    SocketServer.Th readingTCPServe r accepts connections (clients can
    connect) before and after it's server_forever method is called,
    see below for an example.
    >
    IMHO it should only accept connections while server_forever is
    running.
    >
    Kind regards,
    >
    Okko
    serve_forever() only calls accept() in a loop. clients will be able to
    connect up to the backlog of the listen() call.

    -Mark

    Comment

    Working...