node.js / get request & define root folder in http module

I define the next http request:

var http = require("http");
http.get("http://localhost:8001/pro.html", function(respond) {
    check();}).on('error', function(e) {
  console.log("Got err: " + e.message);
});

Now, In the server side I define the next:

var server = net.createServer(function(socket) {
// Some code
socket.on('data', function(d) {
var t = http.request(d, function (res){
            console.log(d);
            console.log(res.statusCode);
        });
// Some code}

I have two problems:

  1. Nothing is printed. Why it doesn't get to console.log(d);console.log(res.statusCode);?
  2. Pro.html is located in c://myFolder. How I tell to my server the location of this page?

Thank you.

It looks like you're trying to use the low-level socket module ('net') to implement an HTTP server. The correct module is 'http' (Node.js HTTP documentation), and the implementation is simple:

Your client side:

var http = require("http");

http.get("http://localhost:8001/pro.html", function(response)
{
    response.setEncoding("utf8");
    response.on("data", function(data)
    {
        console.log("response:", data);
    });

}).on("error", function(e)
{
    console.log("Got err: " + e.message);
});

And for the server side:

var http = require("http");

var server = http.createServer(function(request, response)
{
    response.end("Here's your pro page!\n")

}).listen(8001);

Note that the above features an impractically-simple server that returns a fixed response without any regard to what URL is requested. In any real application you would use some logic to map requested URLs to callback functions (to generate dynamic content), a static file server, an all-encompassing framework (like 'express') or a combination of the above.