Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

add another domain test - broken

  • Loading branch information...
commit 21eb7af902c8508cd4f280857b680f821868bc1a 1 parent b2dac02
ry ry authored

Showing 1 changed file with 63 additions and 0 deletions. Show diff stats Hide diff stats

  1. +63 0 test/simple/test-domains3.js
63 test/simple/test-domains3.js
... ... @@ -0,0 +1,63 @@
  1 +// Copyright Joyent, Inc. and other Node contributors.
  2 +//
  3 +// Permission is hereby granted, free of charge, to any person obtaining a
  4 +// copy of this software and associated documentation files (the
  5 +// "Software"), to deal in the Software without restriction, including
  6 +// without limitation the rights to use, copy, modify, merge, publish,
  7 +// distribute, sublicense, and/or sell copies of the Software, and to permit
  8 +// persons to whom the Software is furnished to do so, subject to the
  9 +// following conditions:
  10 +//
  11 +// The above copyright notice and this permission notice shall be included
  12 +// in all copies or substantial portions of the Software.
  13 +//
  14 +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  15 +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  16 +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  17 +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  18 +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  19 +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  20 +// USE OR OTHER DEALINGS IN THE SOFTWARE.
  21 +
  22 +var common = require('../common');
  23 +var assert = require('assert');
  24 +var domains = require('domains');
  25 +var net = require('net');
  26 +
  27 +var packets = 0;
  28 +
  29 +domains.create(null, function() {
  30 + var domain = this;
  31 +
  32 + // Each connection to the server infinitely receives 'hello world' lines.
  33 + var server = net.Server(function(connection) {
  34 + setInterval(function() {
  35 + connection.write("hello world\n");
  36 + }, 1);
  37 + });
  38 +
  39 + function handleData(d) {
  40 + packets++;
  41 + if (packets == 1000) {
  42 + domain.kill();
  43 + }
  44 + }
  45 +
  46 + server.listen(common.PORT, function() {
  47 + var c1 = net.connect(common.PORT, function() {
  48 + c1.on('data', handleData);
  49 + });
  50 +
  51 + var c2 = net.connect(common.PORT, function() {
  52 + c2.on('data', handleData);
  53 + });
  54 +
  55 + var c3 = net.connect(common.PORT, 'localhost', function() {
  56 + c3.on('data', handleData);
  57 + });
  58 + });
  59 +});
  60 +
  61 +process.on('exit', function() {
  62 + assert.equal(1000, packets);
  63 +});

0 comments on commit 21eb7af

Please sign in to comment.
Something went wrong with that request. Please try again.