Skip to content

Commit 77ee0e2

Browse files
author
alicevm
committed
minor changes
1 parent 62a4319 commit 77ee0e2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

2023-03-28/mytcpserver/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,18 @@ const server = net.createServer();
33

44
server.on("connection", handleConnection);
55

6-
server.listen(12345, "0.0.0.0", () => {
6+
server.listen(5000, "0.0.0.0", () => {
77
console.log(`server listening ${JSON.stringify(server.address())}`);
88
})
99

1010
function handleConnection(socket) {
1111
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+
1220
}

0 commit comments

Comments
 (0)