Avoid socket leaks in examples.
This commit is contained in:
parent
958856f6f1
commit
a44d3f2655
2 changed files with 9 additions and 2 deletions
|
@ -5,10 +5,16 @@ import vibe.core.stream : pipe;
|
|||
|
||||
void main()
|
||||
{
|
||||
listenTCP(7000, (conn) @safe nothrow {
|
||||
auto listeners = listenTCP(7000, (conn) @safe nothrow {
|
||||
try pipe(conn, conn);
|
||||
catch (Exception e)
|
||||
logError("Error: %s", e.msg);
|
||||
});
|
||||
|
||||
// closes the listening sockets
|
||||
scope (exit)
|
||||
foreach (l; listeners)
|
||||
l.stopListening();
|
||||
|
||||
runApplication();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue