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