Skip to content
Snippets Groups Projects
service.c 27.9 KiB
Newer Older
  • Learn to ignore specific revisions
  • Andy Green's avatar
    Andy Green committed
    LWS_VISIBLE int
    lws_service_fd(struct lws_context *context, struct lws_pollfd *pollfd)
    {
    	return lws_service_fd_tsi(context, pollfd, 0);
    }
    
    
     * lws_service() - Service any pending websocket activity
    
     * @context:	Websocket context
     * @timeout_ms:	Timeout for poll; 0 means return immediately if nothing needed
     *		service otherwise block and service immediately, returning
     *		after the timeout if nothing needed service.
     *
     *	This function deals with any pending websocket traffic, for three
     *	kinds of event.  It handles these events on both server and client
     *	types of connection the same.
     *
     *	1) Accept new connections to our context's server
     *
     *	2) Call the receive callback for incoming frame data received by
     *	    server or client connections.
     *
     *	You need to call this service function periodically to all the above
     *	functions to happen; if your application is single-threaded you can
     *	just call it in your main event loop.
     *
     *	Alternatively you can fork a new process that asynchronously handles
     *	calling this service in a loop.  In that case you are happy if this
     *	call blocks your thread until it needs to take care of something and
     *	would call it with a large nonzero timeout.  Your loop then takes no
     *	CPU while there is nothing happening.
     *
     *	If you are calling it in a single-threaded app, you don't want it to
     *	wait around blocking other things in your loop from happening, so you
     *	would call it with a timeout_ms of 0, so it returns immediately if
     *	nothing is pending, or as soon as it services whatever was pending.
     */
    
    LWS_VISIBLE int
    
    lws_service(struct lws_context *context, int timeout_ms)
    
    {
    	return lws_plat_service(context, timeout_ms);
    }
    
    
    Andy Green's avatar
    Andy Green committed
    LWS_VISIBLE int
    lws_service_tsi(struct lws_context *context, int timeout_ms, int tsi)
    {
    	return lws_plat_service_tsi(context, timeout_ms, tsi);
    }