|
@ -27,6 +27,7 @@ var assert = require('assert'); |
|
|
var Buffer = require('buffer').Buffer; |
|
|
var Buffer = require('buffer').Buffer; |
|
|
var dgram = require('dgram'); |
|
|
var dgram = require('dgram'); |
|
|
|
|
|
|
|
|
|
|
|
var debug = false; |
|
|
var tests_run = 0; |
|
|
var tests_run = 0; |
|
|
|
|
|
|
|
|
function pingPongTest(port, host) { |
|
|
function pingPongTest(port, host) { |
|
@ -36,7 +37,7 @@ function pingPongTest(port, host) { |
|
|
var sent_final_ping = false; |
|
|
var sent_final_ping = false; |
|
|
|
|
|
|
|
|
var server = dgram.createSocket('udp4', function(msg, rinfo) { |
|
|
var server = dgram.createSocket('udp4', function(msg, rinfo) { |
|
|
console.log('server got: ' + msg + |
|
|
if (debug) console.log('server got: ' + msg + |
|
|
' from ' + rinfo.address + ':' + rinfo.port); |
|
|
' from ' + rinfo.address + ':' + rinfo.port); |
|
|
|
|
|
|
|
|
if (/PING/.exec(msg)) { |
|
|
if (/PING/.exec(msg)) { |
|
@ -61,7 +62,7 @@ function pingPongTest(port, host) { |
|
|
client = dgram.createSocket('udp4'); |
|
|
client = dgram.createSocket('udp4'); |
|
|
|
|
|
|
|
|
client.on('message', function(msg, rinfo) { |
|
|
client.on('message', function(msg, rinfo) { |
|
|
console.log('client got: ' + msg + |
|
|
if (debug) console.log('client got: ' + msg + |
|
|
' from ' + rinfo.address + ':' + rinfo.port); |
|
|
' from ' + rinfo.address + ':' + rinfo.port); |
|
|
assert.equal('PONG', msg.toString('ascii')); |
|
|
assert.equal('PONG', msg.toString('ascii')); |
|
|
|
|
|
|
|
|