Its not network stream error. Error is caused due to invalid Disconnection of client.
private void RemoveDisconnectedClient(object state)
{
for (int i = 0; i < _Players.Where(x => !isConnected(x.Value.TcpClient.Client)).ToList().Count; i++)
{
KeyValuePair<uint, Client> client = _Players.Where(x => !isConnected(x.Value.TcpClient.Client)).ToList();
if (client.Value.Reason == 1)
{
MSG_ZA2ZS_ACC_LOGOUT pDisconnect = new MSG_ZA2ZS_ACC_LOGOUT();
pDisconnect.MsgHeader.dwPCID = client.Value.Uid;
pDisconnect.byReason = client.Value.Reason;
ZoneServer.ZS[client.Value.ZoneStatus].Send(pDisconnect.Serialize());
}
MSG_ZA2LS_ACC_LOGOUT pLogout = new MSG_ZA2LS_ACC_LOGOUT();
pLogout.MsgHeader.dwPCID = client.Value.Uid;
pLogout.byReason = client.Value.Reason;
pLogout.szAccount = client.Value.Account;
LoginServer.LS.Send(pLogout.Serialize());
_Main.UpdateLogMsg(string.Format("{0} {1} DisconnectedUser.remove", client.Value.Account, client.Value.Uid));
_Players.Remove(client.Key); Main.UpdateConnectionCount(_Players.Count, MaxPlayerCount);
}
}
This was originally foreach loop , i tried for loop but still same issue za crashes.