The main approach I would take to this problem is to use stream2.
My basic approach would be this.
getting data from the first tcp
var gulp = require('gulp')
, thr = require('through2')
;
gulp.watch('rootDirectory/**/*', function(evt) {
if ('deleted' === evt.type) {
return
}
gulp.src(evt.path).pipe(thr(chunk, enc, next){
next(null, fixedChunk)
}).pipe(toYourTcpServer)
})
then on your node
var net = require('net')
, http = require('http')
;
var clientTcp = net.connect({port: 'toYourTcpServerPort'})
var server = http.createServer(function(req, res){
clientTcp.pipe(res)
}).listen('somePort')
node
var clientTcp2 = net.connect({port: 'toYourTcpServerPort2'})
var server2 = http.createServer(function(req, res){
req.pipe(clientTcp2)
}).listen('somePort')
tcp
gutil = require('gulp-util')
clientTcp2.pipe(thr(function(chunk, enc, next){
next(null, fixedChunk)
})).pipe(gulp.dest('finalDirectoy'))
through2 , gulp . - , gulp.
, ,