Added socket javascript code
Translated to Node.js