def handle(self, addrport="", *args, **options):

        if not addrport:
            self.addr = HOST
            self.port = PORT
        else:
            m = match(naiveip_re, addrport)
            if m is None:
                raise CommandError('"%s" is not a valid port number '
                                   'or address:port pair.' % addrport)
            self.addr, _, _, _, self.port = m.groups()

        # Make the port available here for the path:
        #   socketio_tags.socketio ->
        #   socketio_scripts.html ->
        #   io.Socket JS constructor
        # allowing the port to be set as the client-side default there.
        environ["DJANGO_SOCKETIO_PORT"] = str(self.port)

        thread = threading.Thread(target=reload_watcher, args=())
        thread.start()
        try:
            bind = (self.addr, int(self.port))
            print()
            print("SocketIOServer running on %s:%s" % bind)
            print()
            handler = self.get_handler(*args, **options)
            server = SocketIOServer(bind, handler, resource="socket.io")
            server.serve_forever()
        except KeyboardInterrupt:
            client_end_all()
            if RELOAD:
                server.kill()
                print()
                print("Reloading...")
                restart_with_reloader()
            else:
                raise
    def handle(self, addrport="", *args, **options):

        if not addrport:
            self.addr = HOST
            self.port = PORT
        else:
            m = match(naiveip_re, addrport)
            if m is None:
                raise CommandError('"%s" is not a valid port number '
                                   'or address:port pair.' % addrport)
            self.addr, _, _, _, self.port = m.groups()

        # Make the port available here for the path:
        #   socketio_tags.socketio ->
        #   socketio_scripts.html ->
        #   io.Socket JS constructor
        # allowing the port to be set as the client-side default there.
        environ["DJANGO_SOCKETIO_PORT"] = str(self.port)

        start_new_thread(reload_watcher, ())
        try:
            bind = (self.addr, int(self.port))
            print
            print "SocketIOServer running on %s:%s" % bind
            print
            handler = self.get_handler(*args, **options)
            server = SocketIOServer(bind, handler, resource="socket.io")
            server.serve_forever()
        except KeyboardInterrupt:
            client_end_all()
            if RELOAD:
                server.kill()
                print
                print "Reloading..."
                restart_with_reloader()
            else:
                raise