'use strict';

var dgram = require('dgram');
var net = require('net');

function createTCPServer(onListening) {
  var server = net.createServer(function (socket) {
    socket.setEncoding('ascii');
    socket.on('data', function (data) {
      var metrics;
      if (data) {
        metrics = data.split('\n').filter(function (part) {
          return part !== '';
        });
        server.emit('metrics', metrics);
      }
    });
  });

  server.on('listening', function () {
    onListening(server.address());
  });

  server.listen(0, '127.0.0.1');
  return server;
}

function createUDPServer(onListening){
  var server = dgram.createSocket("udp4");
  server.on('message', function(message){
    var metrics = message.toString();
    server.emit('metrics', metrics);
  });

  server.on('listening', function(){
    onListening(server.address());
  });

  server.bind(0, '127.0.0.1');
  return server;
}

module.exports = {
  createTCPServer: createTCPServer,
  createUDPServer: createUDPServer
};

@@ -65,16 +65,397 @@
 net');%0A%0A
+var StatsD = require('../lib/statsd');%0A%0Afunction createStatsdClient(args, noOfChildren) %7B%0A  var client = Array.isArray(args) ? new StatsD(...args) : new StatsD(args);%0A  switch (noOfChildren) %7B%0A    case 0:%0A      return client;%0A    case 1:%0A      return client.childClient(%7B%7D);%0A    case 2:%0A      return client.childClient(%7B%7D).childClient(%7B%7D);%0A    default:%0A      return client;%0A  %7D%0A%7D%0A%0A
 function
@@ -1303,16 +1303,58 @@
 rts = %7B%0A
+  createStatsdClient: createStatsdClient,%0A
   create

Add createStatsdClient test helper