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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:01:37+00:00 2026-06-15T11:01:37+00:00

I saw the next example here var net = require(‘net’); var server = net.createServer(function(c)

  • 0

I saw the next example here

var net = require('net');
var server = net.createServer(function(c) { //'connection' listener
  console.log('server connected');
  c.on('end', function() {
    console.log('server disconnected');
  });
  c.write('hello\r\n');
  c.pipe(c);
});
server.listen(8124, function() { //'listening' listener
  console.log('server bound');
});

So createServer() has an anonymous function as a parameter. The way I see it this function listens and sends back whatever it receives, which is c.

Am I right so far? And where is c coming from?

Thanks!

  • 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-15T11:01:38+00:00Added an answer on June 15, 2026 at 11:01 am

    The c variable is created inside the net.createServer function. c is returned through the callback given as parameter to the createServer function.

    Example:

    function createServer(callback) {
       var c = "hello world";
       callback(c);
    }
    
    createServer(function(c) {
       console.log(c); // Hello world
    });
    

    In your case, c is not a string of course. It was just for the example. It’s another object: a socket.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I saw there is a Radwindow.CloseAll() function in the RadWindow control for ASP.NET AJAX.
xmlDoc.load(cd_catalog.xml) var cd=xmlDoc.getElementsByTagName(CD); var id_set=1; var id=xmlDoc.getElementsByTagName(ID+id_set); i=0; function next() { if (i<id.length-1) {
I'm making a javascript/canvas game and I saw this example on CSS Tricks. Here's
I just saw on the Async CTP website that the next version of VB.NET
I saw that one of our tools uses a ConsoleAppender to System.err next to
I saw some websites that (for example): if you want to view your message
I saw some code when studying the open source project: here . But I
I saw a similar question being posted here, yet it did not help me
I saw an example on the web but now cannot find it any more.
I saw this today in some PHP code: $items = $items ?: $this->_handle->result('next', $this->_result,

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.