Don't rely on a hard-coded port in test.

This commit is contained in:
Sönke Ludwig 2020-03-15 14:01:18 +01:00
parent d2b777607a
commit 0b44d15045

View file

@ -12,7 +12,7 @@ import core.time : msecs;
shared static this() shared static this()
{ {
listenTCP(11375,(conn){ auto l = listenTCP(0, (conn) {
auto td = runTask!TCPConnection((conn) { auto td = runTask!TCPConnection((conn) {
ubyte [3] buf; ubyte [3] buf;
try { try {
@ -22,17 +22,17 @@ shared static this()
}, conn); }, conn);
sleep(10.msecs); sleep(10.msecs);
conn.close(); conn.close();
}); }, "127.0.0.1");
runTask({ runTask({
try { try {
auto conn = connectTCP("127.0.0.1", 11375); auto conn = connectTCP("127.0.0.1", l.bindAddress.port);
conn.write("a"); conn.write("a");
conn.close(); conn.close();
} catch (Exception e) assert(false, e.msg); } catch (Exception e) assert(false, e.msg);
try { try {
auto conn = connectTCP("127.0.0.1", 11375); auto conn = connectTCP("127.0.0.1", l.bindAddress.port);
conn.close(); conn.close();
} catch (Exception e) assert(false, e.msg); } catch (Exception e) assert(false, e.msg);