Dear NaviServer-Friends,

as a small present to the community, i've developed an
additional ensemble named "ns_connchan" which provides
an interface to the driver-receive and driver-send calls
of NaviServer. ns_connchan provides a higher level
alternative to the idiom  "ns_conn channel" + Tcl-commands
which accesses the raw channel

The new command uses the socketcallback infrastructure and allows to
- detach the currently open connection channel from a connection thread, to
- read/write/close the channel from other threads, and to
- query the states to then currently detached channels (similar to 
"ns_writer list")

Advantages:
    * use the same interface for http and https (and other drivers)
    * no (potential) problems with select in Tcl when using
       many (>1024) file descriptors
    * less potential problems with Tcl-Sockets (buffering, translations)
    * lower resource consumption

Implemented interface:

     ns_connchan detach
     ns_connchan close channel
     ns_connchan list ?-server server?
     ns_connchan callback ?-timeout s? ?-receivetimeout s? ?-sendtimeout 
s? channel command when
     ns_connchan read channel
     ns_connchan write channel string

The biggest advantage of "ns_connchan" is that it makes to possible
to read/write to SSL/TLS channels. The new command makes it easy e.g.
- to implement websockets over SSL/TLS (ws://... and wss://...)
- it can be used to implement OpenACS background delivery
   over SSL/TLS (although ns_writer provides already an infrastructure 
for most of it)
- it can be used to implement h264 streaming over SSL/TLS
and many more.

The most important usage scenario for us is currently a wider
usable websocket support. Websockets is facing nowadays
more popularity via  iPython/Jupyter Notebooks and nbviewer.
I've started from an websocket implementation developed by
wolfgang winkler and changed it to the new interfaces.
The new implementation works already nicely for us in
OpenACS. I'll do some more polishing and think
how to provide this as a NaviServer module or similar.

The bitbucket repository contains the source, man page and
test basic test cases for ns_connchan.

All the best in the new year!
-gustaf neumann

PS: A useful extension might be to provide support for multiple
worker threads for socketcallback infrastructure in the future.



------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel

Reply via email to