On Fri, 17 Apr 2015 16:16:38 GMT, Sönke Ludwig wrote:

On Fri, 17 Apr 2015 14:43:09 GMT, doge wrote:

On Fri, 17 Apr 2015 10:10:03 +0200, Sönke Ludwig wrote:
(...)

Sounds like no event loop may be running. Do you use your own main

Yes, but also I am practice unittests-only executions ("dub test")

function, or call some kind of indefinitely blocking function before
leaving static this?

Hmm... My shared static this(){} contains only one line, as an example above.

What is "blocking" in this context? Do I understand correctly that listenTCP is launching an independent thread for listening?

No, by default listenTCP will run in the same thread in which it is called (by using the asynchronous event loop). It thus requires runEventLoop to be called eventually, so if you have a custom main, something like return runEventLoop() should be the last line.

Blocking here would mean that some lengthy computation happens (or I/O, a sleep() call or similar) that doesn't allow the event loop to run. All such operations in vibe.d are made in a way that they automatically cause the event loop to continue when they need to wait for something, but others may not be.

Yes, then - I am forgot to call runEventLoop(). Thanks!

If you want to test listenTCP within a unit test, you can do it using this pattern:

unittest {
	// open the listening socket and
	// register the connection handler
	listenTCP(...);

	// run the test asynchronously
	runTask({
		// connect to the listening socket
		// and perform some tests here
		// ...

		// finally stop the event loop to
		// continue with the next unit test
		exitEventLoop();
	});

	// start event processing
	runEventLoop();
}

Yes, it did. Now everything is clear! Thanks!