Strange. This example crashes (Windows 7 64bit, dmd 2.063.2, driver: libevent):
import vibe.d;
shared static this() {
runTask({
sleep(1.seconds);
listenTCP(8000, (conn){
accept(conn);
}, "127.0.0.1");
auto conn = connectTCP("127.0.0.1", 8000);
logInfo("client: connected");
conn.write("client: hello");
logInfo("client: sent");
ubyte[13] buf;
conn.read(buf);
logInfo("client: received '%s'", cast(string)buf);
});
}
void accept(TCPConnection conn) {
// Trying send and receive in new task
runTask({
conn.write("server: hello");
logInfo("server: sent");
logInfo("server: accepted");
ubyte[13] buf;
conn.read(buf);
logInfo("server: received '%s'", cast(string)buf);
});
}
package.json:
{
"name": "test",
"dependencies": {
"vibe-d": "~master",
}
}
If to comment runTask in accept functions, assertion disappears.