vibe-core/examples/echo-server/source/app.d

21 lines
404 B
D
Raw Normal View History

2017-09-21 12:08:52 +00:00
import vibe.core.core : runApplication;
2020-08-20 02:57:07 +00:00
import vibe.core.log;
2017-09-21 12:08:52 +00:00
import vibe.core.net : listenTCP;
import vibe.core.stream : pipe;
void main()
{
2020-11-25 22:23:58 +00:00
auto listeners = listenTCP(7000, (conn) @safe nothrow {
2020-08-20 02:57:07 +00:00
try pipe(conn, conn);
catch (Exception e)
logError("Error: %s", e.msg);
});
2020-11-25 22:23:58 +00:00
// closes the listening sockets
scope (exit)
foreach (l; listeners)
l.stopListening();
2017-09-21 12:08:52 +00:00
runApplication();
}