NIO+Multithreaded TCPSocket listener, very low cpu utilisation

Daniel Kozak kozzi11 at gmail.com
Thu Nov 16 18:20:36 UTC 2017


Hmm works ok for me. What OS?

Dne 16. 11. 2017 12:05 dop. napsal uživatel "kdevel via
Digitalmars-d-learn" <digitalmars-d-learn at puremagic.com>:

> On Wednesday, 15 November 2017 at 13:31:46 UTC, Daniel Kozak wrote:
>
>> This one works ok for me, but I am on linux:
>> https://dpaste.dzfl.pl/f54decee45bc
>>
>
> It works, but it does not handle two connects in parallel. STR:
>
> 1. start the binary in console 1
> 2. telnet localhost 4444 in console 2
> 3. telnet localhost 4444 in console 3
> 4. enter a [RETURN] in console (3)
>
> observed: nothing (the "thread" handling the first connect blocks)
> expected: response
>
> On my machine defaultPoolThreads() returns 1. This can easily be increased:
>
> ```
>    defaultPoolThreads(8);
> ```
>
> There is also another problem with Socket.select: It may return -1. This
> frequently happens when the ACCEPT socket is non-blocking and the select is
> interrupted (by the GC?) then errno == EINTR.
>
> Also not having a timeout in the Socket.select of handle_socket allows for
> DOS attacks like the one above. In case of a timeout select also returns -1.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20171116/3dddd000/attachment-0001.html>


More information about the Digitalmars-d-learn mailing list