Use this one
public bool Disconnect()
{
if (this.tcpClient != null )
{
try
{
SocketAsyncEventArgs e = new SocketAsyncEventArgs();
this.networkStream.Flush();
this.networkStream.Close();
this.networkStream.Dispose();
tcpClient.Client.Shutdown(SocketShutdown.Both);
this.tcpClient.Client.Close();
this.tcpClient.Close();
GC.Collect();
return true;
}
catch (ObjectDisposedException oex)
{
throw new ObjectDisposedException(base.GetType().FullName);
}
catch
{
return false;
}
}
else
return true;
}