ShrekOverflow
ShrekOverflow

Reputation: 6916

Can Node.js socket handle multiple write messages? Weird bug

I am writing a node.js server and i am experiencing a weird problem heres the code

   socket.write(">> first message \0","utf8",function(){ } );
   socket.write(">> second message \0","utf8",function(){ });

when i listen at the client side (ADOBE FLASH SOCKET) . it only recieves 1 message twice and if i reverse the order of the code the message coming later only gets recieved twice , any clue on how to solve this ?

I am sure that this bug aint in programming because i have checked it like a hundred times, i also tried to make a stack explicitly then found out that node.js is supposed to mantain a stack internally ).


My node version is 0.5.1 running on windows 7 (the windows binary distributed on the website)

Upvotes: 0

Views: 1202

Answers (1)

icktoofay
icktoofay

Reputation: 129039

Try sending the second piece of data in the callback of the first:

socket.write(">> first message \0","utf8",function(){
    socket.write(">> second message \0","utf8",function(){ });
} );

Upvotes: 2

Related Questions