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 8978875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:42:42+00:00 2026-06-15T19:42:42+00:00

What is the difference between: http.Server(function(req,res) {}); and http.createServer(function(req, res) {});

  • 0

What is the difference between:

http.Server(function(req,res) {});

and

http.createServer(function(req, res) {});

  • 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-06-15T19:42:43+00:00Added an answer on June 15, 2026 at 7:42 pm

    Based on the source code of nodejs (extract below), createServer is just a helper method to instantiate a Server.

    Extract from line 1674 of http.js.

    exports.Server = Server;
    
    
    exports.createServer = function(requestListener) {
      return new Server(requestListener);
    };
    

    So therefore the only true difference in the two code snippets you’ve mentioned in your original question, is that you’re not using the new keyword.


    For clarity the Server constructor is as follows (at time of post – 2012-12-13):

    function Server(requestListener) {
      if (!(this instanceof Server)) return new Server(requestListener);
      net.Server.call(this, { allowHalfOpen: true });
    
      if (requestListener) {
        this.addListener('request', requestListener);
      }
    
      // Similar option to this. Too lazy to write my own docs.
      // http://www.squid-cache.org/Doc/config/half_closed_clients/
      // http://wiki.squid-cache.org/SquidFaq/InnerWorkings#What_is_a_half-closed_filedescriptor.3F
      this.httpAllowHalfOpen = false;
    
      this.addListener('connection', connectionListener);
    
      this.addListener('clientError', function(err, conn) {
        conn.destroy(err);
      });
    }
    util.inherits(Server, net.Server);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

t-sql I tried to read the difference between UDF and sprocs, here http://realfantasy.wordpress.com/2009/01/05/sql-server-user-defined-function-udf-vs-stored-procedure-sp/ Do
Can someone explain this to me? In particular the difference between: http://github.com/whymirror/greg and http://piumarta.com/software/peg/
What's the difference between an HTTP query parameter and an HTTP form parameter? I
What is the difference between net.tcp and http?
What is the difference between... http://mysite.com/12345 and http://mysite.com/an6 I am wondering because it would
Why is the difference between the two addresses wrong? http://codepad.org/NGDqFWjJ #include<stdio.h> int main() {
I am trying to figure out the difference between Google's GData API ( http://code.google.com/p/gdata-python-client/
Can someone explain the difference between the HTTP request and it handling and socket
Difference between start-pointers and interior-pointers and in what situation we should prefer one over
The difference between Chr and Char when used in converting types is that one

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.