Reputation: 2079
I was looking for the simple step by step communication tutorial for .Net programmers. After some Google queries, I have found the "CSharp Communications" code collections at net-informations.com. It looked quite good as long as I reached the "How to C# Chat Server" example.
Authors propose multithreaded server with the HashTable container to keep all connections in the shared memory at the server side. According to MSDN documentation TcpClient and NetworkStream classes used for broadcast messages are not thread safe, while the example uses them from multiple server threads.
My questions are:
Upvotes: 4
Views: 6600
Reputation: 109140
According to MSDN documentation TcpClient and NetworkStream classes used for broadcast messages are not thread safe, while the example uses them from multiple server threads.
This is correct; but it is about concurrent access. If each thread uses the instance in turn (eg. using locks to control access) then different threads can be used.
In other words: not thread safe does not imply tied to a single thread.
Upvotes: 1
Reputation: 6159
It is not perfect as I wrote it almost 7 years ago, but it is covering and will give you good understanding regarding the field of TCP communications:
Upvotes: 6