title: Client/Server Programming, Cannot convert System.net.IPAddress to String
body: <p>Im developing a client server program. On the client side i developed a program that sends data and receives data. </p>
  
  <p>I managed to parse a static ip address but i tried using IPAddress.Any but it returns that error. (Cannot convert System.net.IPAddress to String). </p>
  
  <pre><code>using System;
  using System.Net;
  using System.Net.Sockets;
  using System.Text;
  
  namespace client
  {
      class HMSClient
      {
          static void Main(string[] args)
          {
              try
              {
                  //---Connect to a port
                  Console.Write("Input port" + System.Environment.NewLine);
                  int PORT_NO = int.Parse(Console.ReadLine());
                  Console.Write("Input a Command" + System.Environment.NewLine);
                  while (true)
                  {
                      //---data to send to the server---
                      string commands = Console.ReadLine();
  
                      //---create a TCPClient object at the IP and port no.---
                      //IPAddress SERVER_IP = Dns.GetHostEntry("localhost").AddressList[0];
  
                      TcpClient client = new TcpClient(IPAddress.Any, PORT_NO);
  
                      NetworkStream nwStream = client.GetStream();
                      byte[] bytesToSend = Encoding.ASCII.GetBytes(commands);
  
                      //---send the command---
                      Console.WriteLine("Command: " + commands);
                      nwStream.Write(bytesToSend, 0, bytesToSend.Length);
  
                      //---read back the response
                      byte[] bytesToRead = new byte[client.ReceiveBufferSize];
                      int bytesRead = nwStream.Read(bytesToRead, 0, client.ReceiveBufferSize);
                      Console.WriteLine("Response: " + Encoding.ASCII.GetString(bytesToRead, 0, bytesRead));
                  }
              }
              catch (Exception e)
              {
                  Console.WriteLine("Client cannot find target to send the command" + Environment.NewLine + e);
                  Console.ReadLine();
              }
          }
      }
  }
  </code></pre>