Last active
January 22, 2023 16:34
-
-
Save tikarammardi/ae9b573c360f4f77f9931b5a70daa5da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const net = require("net"); | |
const port = process.env.PORT ?? 3000; | |
const server = net.createServer((socket) => { | |
console.log("Client connected"); | |
socket.on("data", (data) => { | |
console.log(`Server Received msg: ${data}`); | |
socket.write(`Server has received your message: ${data}`); | |
}); | |
socket.on("end", () => { | |
console.log("Client disconnected"); | |
}); | |
}); | |
server.listen(port, () => { | |
console.log(`Server listening on port ${port}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment