B2G/gecko/netwerk/test/unit/test_net_addr.js
/**
 * TestServer: A single instance of this is created as |serv|.  When created,
 * it starts listening on the loopback address on port |serv.port|.  Tests will
 * connect to it after setting |serv.acceptCallback|, which is invoked after it
 * accepts a connection.
 *
 * Within |serv.acceptCallback|, various properties of |serv| can be used to
 * run checks. After the callback, the connection is closed, but the server
 * remains listening until |serv.stop|
 *
 * Note: TestServer can only handle a single connection at a time.  Tests
 * should use run_next_test at the end of |serv.acceptCallback| to start the
 * following test which creates a connection.
 */
A single instance of this is created as |serv|.  When created,
it starts listening on the loopback address on port |serv.port|.  Tests will
connect to it after setting |serv.acceptCallback|, which is invoked after it
accepts a connection.

Within |serv.acceptCallback|, various properties of |serv| can be used to
run checks. After the callback, the connection is closed, but the server
remains listening until |serv.stop|

TestServer can only handle a single connection at a time.  Tests
should use run_next_test at the end of |serv.acceptCallback| to start the
following test which creates a connection.
A single instance of this is created as |serv| . When created it starts listening on the loopback address on port |serv . port| . Tests will connect to it after setting |serv . acceptCallback| which is invoked after it accepts a connection . Within |serv . acceptCallback| various properties of |serv| can be used to run checks . After the callback the connection is closed but the server remains listening until |serv . stop| TestServer can only handle a single connection at a time . Tests should use run_next_test at the end of |serv . acceptCallback| to start the following test which creates a connection .
function TestServer() {
  this.reset();
  this.listener = ServerSocket(-1, true, -1);
  this.port = this.listener.port;
  do_print('server: listening on', this.port);
  this.listener.asyncListen(this);
}
function TestServer ( ) { this . reset ( ) ; this . listener = ServerSocket ( - 1 , true , - 1 ) ; this . port = this . listener . port ; do_print ( 'server: listening on' , this . port ) ; this . listener . asyncListen ( this ) ; }
TestServer: A single instance of this is created as |serv|.
TestServer : A single instance of this is created as |serv| .
// start server. // any port (-1), loopback only (true), default backlog (-1)