vibe-core/examples/echo-server/source/app.d
2020-11-25 23:23:58 +01:00

21 lines
404 B
D

import vibe.core.core : runApplication;
import vibe.core.log;
import vibe.core.net : listenTCP;
import vibe.core.stream : pipe;
void main()
{
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();
}