How to manage threads on a TCP duplex connection?

I need to implement a TCP client (in .NET) that keeps a TCP connection open with a remote point, sends keep-alive signals to keep the connection alive and is able to receive data at any time and/or send data at any time. However, the difficulty for me is that I’m not sure how to do this efficiently. For instance, I would like to use as few threads as possible or even less than one per connection.

I’ve previously developed some TCP clients that seem to work fine, but I believe they weren’t implemented in the right way. For example, they use one thread for incoming and another for outgoing, and they are vulnerable to potential DDoS attacks that exploit these thread limitations.

I’d like advice on the fundamental concepts I should pursue in order to implement a secure and high performance TCP connection or directions I can follow to obtain more in-depth knowledge.

Additional details on the sort of TCP connection I need

I need to be able to send and/or receive data on this connection at any time, asynchronously. Any kind of data, from simple notifications or messages to very large files.

Asked on July 16, 2020 in .NET,   ASP.net.
Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.