use window.location.hostname instead of localhost to conect client socke...

...t