0

Similar to this question for Express, is there a programmatic way to get the host name and port number of a running Connect server?

aynber
  • 22,380
  • 8
  • 50
  • 63
XåpplI'-I0llwlg'I -
  • 21,649
  • 28
  • 102
  • 151
  • I guess it depends on what you actually mean? Are talking how do you determine that within your own code of your own connect server or are you talking about how you determine that in some already running application. Do you want to know that in the context of a request? etc, etc, etc – Edwin Dalorzo Jun 07 '14 at 13:19

2 Answers2

0

It's simple:

var http = require('http');
var connect = require('connect');
var app = connect().use(connect.static(__dirname)); //or any other use
var server = http.createServer(app).listen(port, host, callback);
rafaelcastrocouto
  • 11,781
  • 3
  • 38
  • 63
0

Figured it out:

var connect = require("connect");
var server = require("http").createServer(connect());
server.listen(function() {
  console.log(server.address()); // Print host name and port number.
});
XåpplI'-I0llwlg'I -
  • 21,649
  • 28
  • 102
  • 151