title: TCP Socket send/receive always waiting
body: <p>I have a <code>TCP</code> connection between a server and a client. Server sending data, client receiving data and client feedback the server. But if client closes socket and creates again, server never accept it because it is waiting feedback from client. So how can i solve that?</p>
  
  <p><strong>Server</strong></p>
  
  <pre><code>byte[] buffer = new byte[1000];
  string ip = "192.168.1.17";
  int port = 15500;
  
  IPAddress ipAddress = IPAddress.Parse(ip);
  IPEndPoint localEndpoint = new IPEndPoint(ipAddress, port);
  
  Socket sock = new Socket(ipAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
  
  Console.WriteLine("Waiting client...");
  sock.Bind(localEndpoint);
  sock.Listen(5);
  
  Socket confd = sock.Accept();
  
  Console.WriteLine("Connected with {0} at port {1}", ip, port);
  Sender sender = new Sender();
  Receiver receiver = new Receiver();
  
  while (true) {
      if (confd.Connected) {
          sender.SendData(confd);
          receiver.ReceiveData(confd); //Waiting here
      } 
      else {
          confd.Close();
          Console.WriteLine("Waiting client...");
          confd = sock.Accept();
      }
  }
  </code></pre>