title: Reconnect to the server
body: <p>My Tcpclient did not disconnect properly I am using Client async.<br />
  I want to reconnect again automatic when server disconnect.<br />
  What is correct path?</p>
  <h3>This is Connection code</h3>
  <pre><code>private void Connect_btn_Click(object sender, EventArgs e)
  {
      try
      {
          if (IsConnected == false)
          {
              constatus.Text = &quot;Connecting.....&quot;;
              newsock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
              //IPEndPoint iep = new IPEndPoint(IPAddress.Any, 20);
              IPEndPoint iep = new IPEndPoint(IPAddress.Parse(IP), Convert.ToInt16(PORT));
              newsock.BeginConnect(iep, new AsyncCallback(Connected), newsock); 
          }
          else 
          {
              MessageBox.Show(&quot;Connection is Already Connected&quot;);
          }
      }
      catch (Exception)
      {
          MessageBox.Show(&quot;Please Enter IPAddress and Port Address&quot;,&quot;Error&quot;,MessageBoxButtons.OK,MessageBoxIcon.Information);   
      }
  } 
  </code></pre>
  <hr />
  <pre><code>       //This is Connected Function IASYNCHRESLT interface using call back
          //Connected Function Call Back Asynch use in Connection button
    void Connected(IAsyncResult iar)
     {All Commands Inputs Send Fucntion Calling}
      {
          try
          { 
              client = (Socket)iar.AsyncState;
              client.EndConnect(iar);
              this.Invoke(new viewStatus(setValue), &quot;Connected&quot;);
              //constatus.Text = &quot;Connected To:&quot; + client.RemoteEndPoint.ToString();
              client.BeginReceive(data, 0, size, SocketFlags.None, new AsyncCallback(ReceiveData), client);
              GetAllDateHide_performClick();
              
          }
          catch (SocketException)
          {
              ErrorConnecting();
          }
      }
  </code></pre>
  <p>this is disconnect code</p>
  <pre><code>private void ButtonDisconnect_Click(object sender, EventArgs e)
  {
      try
      {
          client.Close();
          constatus.Text = &quot;Disconnected&quot;;
      }
      catch (Exception) { }
  }
  </code></pre>
  <p>and  how to  handle the ObjectDisposed Exception i will disconnect</p>