As I see Node JS can't send string to client.
When I use socket.write("string")
client doesn't receive anything. socket.write(new Buffer("string"))
— same situation.
var b = new Buffer(15);
b.write("string");
socket.write(b);
It looks like something works, but client receives string along with a lot of blank space.
var b = new Buffer(6); //6 - lenght of string in bytes
b.write("string");
socket.write(b);
Again nothing!
var b = new Buffer(7);
b.write("string");
socket.write(b);
Now there's less blank characters.
My head really hurts. Is it really complicated to send simple string?
Waiting for my savior :)
socket.write("string")
actually works fine. Check the docs.
You forgot to end the transmission, after each write do a socket.end();
Also, if you're only sending one string you can always do a socket.end(stringToSend);
Please also refer to NodeJS documentation of the modul 'net'.