node.js - pipe tcp client data to http response ,get: 'res not defined' -
how pipe tcp client data http response ? cannot find complete example that.
var ohttp = require("http") ohttp.createserver(function(req, res) { var query = req.url.split('?')[1]; otcp.write(query +'\n') ; }).listen(port);
get data tcp client http 'res' object using pipe :
var onet = require('net'); otcp = new onet.socket(); otcp.connect(port, host, function() { console.log('tcp.client listen @ port ' + port ) this.pipe(res); });
got error node.js 'this.pipe(res);' not defined on object 'res'
what want achieve :
- declare http serever
connect once tcp client.
from http serever (req,res) cycle write tcp client query string
get response tcp client pipe , bypass on('data',...) event handlings pipe 'know target stream 'res' streamer, if understand.
in examples see, develoeprs putting tcp.connect inside scope of http.createserver loop cycle ?? make tcp connect on each (req,res) ?
i need make on once tcp connect , pipe http response's after each tcp.client write.
Comments
Post a Comment