I've got a TCP socket in which I listen for data send from a device. This 
works, but when I connect to that socket connection with 
"net.createConnection" (from another part of the code) the incoming data 
does not get send BACK to the device. 

Does anyone know why the data is not send back to the device? I checked 
with wireshark, the data is not send. It works when I send data from within 
the socket connection (not from the "createConnection" part)

    // connector to tcp listener
>     var returnsock = net.createConnection(4102, function() {
>         returnsock.write(msg); 
>     });
>     // listener
> var lPORT = 4102;
>
> // Create a server instance, and chain the listen function to it
> net.createServer({allowHalfOpen:true}, function(sock) {
>
> sock.setKeepAlive(true);
>
> // We have a connection - a socket object is assigned to the connection 
> automatically
> console.log('TCP LISTENER hearing on: ' + sock.remoteAddress +':'+ 
> sock.remotePort);
>
> // Event handler: incoming data
> sock.on('data', function(data) {
>
> var sockwrite = sock.write(data);
> if (sockwrite === true) {
> console.log(''+data);
> }
> //sock.pipe(sock);
>
> // Write incoming messages to logfile.
> var log = fs.createWriteStream('pin.log', {'flags': 'a'});
> log.write(data+'\n\r\n\r');
> // Write incoming messages to logfile.
> var log = fs.createWriteStream('port.inc', {'flags': 'w'});
> log.write(sock.remotePort); 
>
> // Push incoming messages to client
> io.of('/process').emit( 'broadcast_msg', ''+data);
>
> });
>
> // Event handler: close connection
> sock.on('close', function(data) { 
> console.log('[LISTENER] Connection paused.');
> });
>
> }).listen(lPORT); 


Yes, the incoming data is "logged" with console.log, it is sock.write() 
that is not working.

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to