Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7185157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:21:15+00:00 2026-05-28T18:21:15+00:00

I’m quite new to Node.js, so please bear with me… Bascially, I have a

  • 0

I’m quite new to Node.js, so please bear with me…

Bascially, I have a proxy server, and I want to intercept HTTP body packets. These packets are fired off through zeromq to another process outside of Node.js (a C program) and the response (the modified packet), must be written back out as the response from the proxy. I hope I’m making sense.

I’ve commented the code with the bits I’m stuck with

Here is my javascript code:

var http = require('http');
var util=require('util');
var net=require('net');
var context = require('zmq');

// socket to talk to server
util.puts("Connecting to server...");
var requester=context.createSocket('req');

requester.on("message",function(reply) {
        util.puts("Received reply"+reply.toString());

        //response.write(reply,'binary');   //how do I pick up the `response` variable inside the proxy callback and write with it?!
})

requester.connect("ipc://myfd.ipc")

process.on('SIGINT', function() {
        requester.close()
})




http.createServer(function(request, response) {
        var proxy=http.createClient(80,request.headers['host']);
        var proxy_request=proxy.request(request.method,request.url,request.headers);

        proxy_request.addListener('response',function (proxy_response){
                proxy_response.addListener('data',function(chunk){
                        //util.puts(chunk);

                        requester.send(chunk);   //ok, my C program can read chunks

                        response.write(chunk,'binary');   //I don't want to do this - I want to write the response of `requester.send(chunk)`
               });
                proxy_response.addListener('end',function(){
                        //util.puts("end");
                        response.end();
                });
                response.writeHead(proxy_response.statusCode,proxy_response.headers);
        });


        request.addListener('close',function(){
                //util.puts("close");
        });
        request.addListener('data',function(chunk){
                //util.puts("data");
                proxy_request.write(chunk,'binary');
        });
        request.addListener('end',function(){
                //util.puts("end");
                proxy_request.end();
        });
}).listen(8080);

I hope someone can help…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T18:21:18+00:00Added an answer on May 28, 2026 at 6:21 pm

    as Pointy alread has pointed out (i see what you did there 😉 ), you need to make requester.send(chunk); asynchronous by adding a callback, which gets invoked as soon as your C Program is finished doing what it does. You also could do it non-async ( -> synchronous) by directly returning the value.

    I’d dig in some tutorials about “how to make your own node.js module with bindings”;

    1. Good Overview
    2. Simple Async Module by Isaac Schleuters himself
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.