-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating an UDP server is cumbersome #289
Comments
Additionally, calling if (cmdline_args.dns)
{
auto udp = listenUDP(53);
runTask({
while (true) {
auto pack = udp.recv();
logInfo("Got packet: %s", pack);
}
});
}
return runEventLoop(); And got an error. Moving the |
I've tried this recently and it seems to be working properly now. |
you shoud use listenUDP on run Task. if (cmdline_args.dns)
{
runTask({
auto udp = listenUDP(53);
ubyte[] buffer = cast(ubyte[]) Mallocator.instance.allocate(2048);
scope(exit) Mallocator.instance.deallocate(cast(void[]) buffer);
while (true) {
auto pack = udp.recv(buffer,null);
logInfo("Got packet: %s", pack);
}
});
}
return runEventLoop(); |
If the fiber is in the same thread it should not make a difference. Also in this case I think we were saving the listener somewhere so we could shut it down when the user pressed Ctrl+C, so it wasn't actually an option. |
Creating a TCP server is rather straightforward and documented.
However, as I tried to create an UDP server, I hit a few issues:
recv
, which will throw on timeout.The text was updated successfully, but these errors were encountered: