I was looking for a simple step-by-step tutorial for .Net programmers. After some Google searches, I found a collection of "CSharp Communications" codes at net-informations.com. It looked pretty good until I got to the How to C # Chat Server example .
The authors propose a multi-threaded server with a HashTable container for storing all connections in the shared memory on the server side. According to the MSDN documentation TcpClient and NetworkStream, the classes used for broadcast messages are not thread safe, and the example uses them from several server threads.
My questions:
- Could you confirm that the example is incorrect?
- How to do this, is it enough to block the broadcast method (mark it as a critical section)?
- Could you advise some tutorials for sockets (preferable?)?
source
share