Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test-dgram-multicast-setTTL.js « parallel « test - github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d849945fab78377fd7c9e7877b49ce1c8f8c0b5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
var common = require('../common'),
    assert = require('assert'),
    dgram = require('dgram'),
    thrown = false,
    socket = dgram.createSocket('udp4');

socket.bind(common.PORT);
socket.on('listening', function () {
  socket.setMulticastTTL(16);

  //Try to set an invalid TTL (valid ttl is > 0 and < 256)
  try {
    socket.setMulticastTTL(1000);
  } catch (e) {
    thrown = true;
  }

  assert(thrown, 'Setting an invalid multicast TTL should throw some error');

  //close the socket
  socket.close();
});