You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
557 B
29 lines
557 B
|
7 months ago
|
var net = require('net'),
|
||
|
|
nssocket = require('../lib/nssocket');
|
||
|
|
|
||
|
|
net.createServer(function (socket) {
|
||
|
|
//
|
||
|
|
// Close the underlying socket after `1000ms`
|
||
|
|
//
|
||
|
|
setTimeout(function () {
|
||
|
|
socket.destroy();
|
||
|
|
}, 1000);
|
||
|
|
}).listen(8345);
|
||
|
|
|
||
|
|
//
|
||
|
|
// Create an NsSocket instance with reconnect enabled
|
||
|
|
//
|
||
|
|
var socket = new nssocket.NsSocket({
|
||
|
|
reconnect: true,
|
||
|
|
type: 'tcp4',
|
||
|
|
});
|
||
|
|
|
||
|
|
socket.on('start', function () {
|
||
|
|
//
|
||
|
|
// The socket will emit this event periodically
|
||
|
|
// as it attempts to reconnect
|
||
|
|
//
|
||
|
|
console.dir('start');
|
||
|
|
});
|
||
|
|
|
||
|
|
socket.connect(8345);
|