We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 62a4319 commit 77ee0e2Copy full SHA for 77ee0e2
2023-03-28/mytcpserver/index.js
@@ -3,10 +3,18 @@ const server = net.createServer();
3
4
server.on("connection", handleConnection);
5
6
-server.listen(12345, "0.0.0.0", () => {
+server.listen(5000, "0.0.0.0", () => {
7
console.log(`server listening ${JSON.stringify(server.address())}`);
8
})
9
10
function handleConnection(socket) {
11
console.log(`Nuevo cliente desde ${socket.remoteAddress}:${socket.remotePort}`);
12
+ socket.setEncoding("utf8");
13
+ socket.on("data", onConnData);
14
+
15
+ function onConnData(data) {
16
+ socket.write(data.toUpperCase());
17
+ }
18
19
20
}
0 commit comments