Skip to content

Instantly share code, notes, and snippets.

@ferdousulhaque
Created April 13, 2023 13:25
Show Gist options
  • Save ferdousulhaque/8b5a7a3b21d2d9871af8a914fb1c6e74 to your computer and use it in GitHub Desktop.
Save ferdousulhaque/8b5a7a3b21d2d9871af8a914fb1c6e74 to your computer and use it in GitHub Desktop.
Listener script with node to test server port opening
const http = require("http");
const host = process.argv.slice(2)[0];
const port = process.argv.slice(2)[1];
const requestListener = function (req, res) {
res.writeHead(200);
res.end("Success!!");
};
const server = http.createServer(requestListener);
server.listen(port, host, () => {
console.log(`Server is running on http://${host}:${port}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment