1 // Opening a second listening socket on the same address as an extant
2 // socket should elicit NS_ERROR_SOCKET_ADDRESS_IN_USE on non-Windows
7 var CC
= Components
.Constructor
;
9 const ServerSocket
= CC(
10 "@mozilla.org/network/server-socket;1",
15 function testAddrInUse() {
16 // Windows lets us have as many sockets listening on the same address as
17 // we like, evidently.
18 if (mozinfo
.os
== "win") {
22 // Create listening socket:
23 // any port (-1), loopback only (true), default backlog (-1)
24 let listener
= ServerSocket(-1, true, -1);
25 Assert
.ok(listener
instanceof Ci
.nsIServerSocket
);
27 // Try to create another listening socket on the same port, whatever that was.
28 do_check_throws_nsIException(
29 () => ServerSocket(listener
.port
, true, -1),
30 "NS_ERROR_SOCKET_ADDRESS_IN_USE"