DEV Community

[Comment from a deleted post]
Collapse
 
euantorano profile image
Euan T • Edited

Unfortunately it looks like this library doesn't support cancellation as far as I can see.

When I want to do socket programming in .net, I always find that the lower level Socket type is the best option, as it handles cancellation, can work with the new Memory<T> types, etc. so implementing a high performance client/server is made relatively easy.

Take, for example, the method signature for Socket.SendAsync. You can pass in a memory type, and it supports cancellation. Under the hood it will make use of a SocketAsyncEventArgs pool which will be familiar to anybody who’s used sockets in .net in an asynchronous manner even before the async/await support was available.

The TcpClient and UdpClient types only complicate things in my opinion.