blob: d25860e8965811a45cdae32074f1f10165cabbd0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
// Opening a second listening socket on the same address as an extant
// socket should elicit NS_ERROR_SOCKET_ADDRESS_IN_USE on non-Windows
// machines.
"use strict";
var CC = Components.Constructor;
const ServerSocket = CC(
"@mozilla.org/network/server-socket;1",
"nsIServerSocket",
"init"
);
function testAddrInUse() {
// Windows lets us have as many sockets listening on the same address as
// we like, evidently.
if (mozinfo.os == "win") {
return;
}
// Create listening socket:
// any port (-1), loopback only (true), default backlog (-1)
let listener = ServerSocket(-1, true, -1);
Assert.ok(listener instanceof Ci.nsIServerSocket);
// Try to create another listening socket on the same port, whatever that was.
do_check_throws_nsIException(
() => ServerSocket(listener.port, true, -1),
"NS_ERROR_SOCKET_ADDRESS_IN_USE"
);
}
function run_test() {
testAddrInUse();
}
|