Sunday, October 6, 2013

The web socket server implementation on Python

Recently, the Java Applets Sand Box were breached by hacker and cause a lot of security event on web. Therefore, the last sand box would be the browser itself. (If there is no trust-able sand box, I don't know how to build up a reliable infra on WWW.) And I used to write the TCP/IP Socket in Applet for real-time application on web. Therefore I turned into a new standard which is still in draft of W3C - Web Socket.
I have learned there is a client implementation in JavaScript for web socket - socket io. And also there are several server implementation on web socket including the Python. However, I found this implementation is quiet bit experimental-wise. First, its base library is called gevent-socketio which is the web socket server implementation that depends on gevent, greenlet and libevent. And those three libraries are pretty nasty when I try to build the package environment including them. First I have to let Python learn the compiler's setting to build libevent and hence the gevent and greenlet would be installed successfully. But I quit this way because my window's machine is too clumsy and no more 10 GB for visual studio as a compiler. So I choose the web site http://www.lfd.uci.edu/~gohlke/pythonlibs/ which provide the built binary for windows installation.
After I install the gevent and greenlet, I can easily use pip to install the gevent-websocket. (off course you should  install the easy_install tool package first which is still a binary installation from https://pypi.python.org/pypi/setuptools. After all, we are dealing with windows without apt-get). The package of gevent-websocket is the protocol implementation for web socket standard and pretty easy to be install once you have easy_install set up.
So my Python Interpreter can run the script without error now. It's time to try the web socket server of Python. Since I couldn't afford a Mac or event Chrome book, I think this is the only way that dive into Python's world.

No comments:

Post a Comment