On Thu, 06 Feb 2014 14:04:37 +0100, Sönke Ludwig wrote:
You need to have an existing FD (a socket of some kind) that is set to
non-blocking mode. You then create aFileDescriptorEvent
and usewait
in the same situation that you'd normally useselect
to wait
for data:auto evt = createFileDescriptorEvent(fd, FileDescriptorEvent.Trigger.any); // read someting while (true) { auto ret = recv(fd, but.ptr, buf.length, 0); if (ret < 0 && errno == EWOULDBLOCK) { // wait until data is available for read evt.wait(FileDescriptorEvent.Trigger.read); } else { // handle error or received data } }
Just to make sure:
In this case there are will not created extra CPU thread for waiting socket event?
Events lib tracks events on the socket by the operating system functional (callbacks or something like from already existing OS thread)?