単純な TCP サーバーを構築しましたが、クライアント入力を変数に格納されているハードコードされた文字列と比較する必要があります。
ただし、data == username常に失敗します。
なんで?私はそれについて何ができますか?
例:
var authenticateClient = function(client) {
    client.write("Enter your username:");
    var username = "eleeist";
    client.on("data", function(data) {
        if (data == username) {
            client.write("username success");
        } else {
            client.write("username failure");
        }
    });
}
var net = require("net");
var server = net.createServer(function(client) {
    console.log("Server has started.");
    client.on("connect", function() {
        console.log("Client has connected.");
        client.write("Hello!");
        authenticateClient(client);
    });
    client.on("end", function() {
        console.log("Client has disconnected.");
    });
}).listen(8124);