1 /* Copyright 2015-present Samsung Electronics Co., Ltd. and other contributors
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
17 var net = require('net');
18 var assert = require('assert');
23 var server = net.createServer();
25 server.listen({ port: port });
27 server.on('connection', function(socket) {
29 var writing = function() {
32 ok = socket.write("" + (i % 10));
39 socket.on('drain', writing);
45 var socket1 = net.createConnection(port);
47 socket1.on('data', function(data) {
53 var socket2 = net.createConnection({port: port});
55 socket2.on('data', function(data) {
61 var socket3 = net.createConnection({port: port, host: '127.0.0.1'});
63 socket3.on('data', function(data) {
69 var connectListenerCheck = false;
70 var socket4 = net.createConnection({port: port}, function() {
71 connectListenerCheck = true;
74 socket4.on('data', function(data) {
78 socket4.on('end', function() {
83 process.on('exit', function(code) {
84 assert.equal(msg1.length, limit);
85 assert.equal(msg2.length, limit);
86 assert.equal(msg3.length, limit);
87 assert.equal(msg4.length, limit);
88 assert(connectListenerCheck);