I am trying to implement a simple websoket server on python, using RFC 6455 protocol. I took handshake format from here and here.
I am using Chromium 17 and Firefox
Your server handshake code looks good.
The client code looks like it'll try to send a message before the (asynchronous) handshake completes however. You could avoid this by moving your message send into your websocket's onopen method.
Once the connection is established, the server does not send or receive messages as plain text. See the data framing section of the spec for details. (Client code can ignore this as the browser takes care of data framing for you.)