JavaScript does not have any networking facilities. Those are part of the browser, so if you run JS outside a browser, you can't do this. Unless, of course, you're using Rhino (a JS engine implemented in
Java), which has access to Java classes. Then you can use a library like Commons Net to perform the networking operations. But that wouldn't be the same as doing it in JS.