TcpClient, TcpListener, NetworkStream
<p>I have created an Instant Messanger that allows communication between clients through a server.</p>

<p>The server stores the NetworkStream and username of the clients which are logged in, and the message sent from the client is used to ascertain to whom the server should route the message too.</p>

<p>The problem I am having is that the first two messages from one client to another works, e.g:</p>

<ul>
<li>Client1 sends message to Client2</li>
<li>Server receives client1's message and routes to client2 (target)</li>
<li>Client2 Receives message (presents)</li>
</ul>

<p>And vice vercia.</p>

<p>After the initial message is sent by client1, client2 does not receive messages from client1 ever again.</p>

<p>The problem I see is that the server does indeed receive the messages and seems to send it to the right stream, but the intended client doesn't receive it.</p>

<p>The receiving client in this situation, client2 cannot/does not receive messages, but can send messages and client1 does receive them.</p>

<p>If any more information is needed please let me know.</p>

<p>I can guarentee that the code I am using is accurate, the only thing I can think of is in the nature of the networkstream or tcpclient.</p>

<pre><code>                int accountThreadCount = 0;
                while (accountThreadCount &lt; login.newClientLogin.clientList.Count())
                {
                    AccountThread newAccountThread = login.newClientLogin.clientList[accountThreadCount];
                    if (newAccountThread.username == comm.to)
                    {
                        Stream relayMessageStream = newAccountThread.tcpc.GetStream();
                        iff.Serialize(relayMessageStream, comm);
                    }
                    accountThreadCount++;
                }
</code></pre>

<p>AccountThread stores, the TcpClient and username and other things.
Now assuming that this is working perfectly, as it is otherwise the first two wouldn't work. As I have already said above this is very peculiar to me, I have tried re-coding to no avail.</p>
