Module bjsonrpc.server

class bjsonrpc.server.Server(lstsck, handler_factory)

Handles a listening socket and automatically accepts incoming connections. It will create a bjsonrpc.connection.Connection for each socket connected to it.

Use the Server.serve() method to start accepting connections.

Parameters:

lstsck
Listening socket to watch for incoming connections. Must be an instance of socket.socket or something compatible, and must to be already listening for new connections in the desired port.
handler_factory
Class (object type) to instantiate to publish methods for incoming connections. Should be an inherited class of bjsonrpc.handlers.BaseHandler
debug_dispatch(value=None)

Sets or retrieves the internal debug_dispatch value.

When is set to true, each new connection will have it set to true, and every error produced by client connections will be printed to stdout.

By default is set to False

debug_socket(value=None)

Sets or retrieves the internal debug_socket value.

When is set to true, each new connection will have it set to true, and every data sent or received by the socket will be printed to stdout.

By default is set to False

serve()

Starts the forever-serving loop. This function only exits when an Exception is raised inside, by unexpected error, KeyboardInterrput, etc.

It is coded using select.select function, and it is capable to serve to an unlimited amount of connections at same time without using threading.

stop()

Tells the server that it should stop. Useful in multithread apps. Once stopped, call again to serve() to start the server loop again.

Previous topic

Application Programming Interface (API)

Next topic

Module bjsonrpc.connection

This Page