I use this code in my project: https://github.com/ncr/node.ws.js/blob/master/ws.js
With Opera, Safari, and FF it works perfectly, but with googlechrome it doesn’t works, because chrome use an other protocol (draft-ietf-hybi-thewebsocketprotocol-08)
I can’t setup socket.io, so I have to modify this code: https://github.com/ncr/node.ws.js/blob/master/ws.js
To send the handshake you need to implement the algorithm as it is defined:
For sending and receiving messages please see this wiki question.