title: UDP Bind Method
body: <p>I am trying to set up a UDP communication link between 2 computers.  One computer is running the client app and the other is running the server app.  The client app gives the error:</p>
  
  <p><strong>You must call the Bind method before performing this operation.</strong></p>
  
  <p>Here is my code below for the client below and I have commented where the error occurs:</p>
  
  <pre><code> public delegate void ShowMessage(string message);
      UdpClient udpClient = new UdpClient();
      Int32 port = 11000;
      public ShowMessage myDelegate;
      Thread thread;
  
  
  private void Form1_Load(object sender, EventArgs e)
      {
          thread = new Thread(new ThreadStart(ReceiveMessage));
          thread.IsBackground = true;
          thread.Start();
      }
  
  
      private void ReceiveMessage()
      {
          while (true)
          {
              IPEndPoint remoteIPEndPoint = new IPEndPoint(IPAddress.Any, port);
  
              //Error on this line
              byte[] content = udpClient.Receive(ref remoteIPEndPoint);
  
              if (content.Length &gt; 0)
              {
                  string message = Encoding.ASCII.GetString(content);
  
  
                  this.Invoke(myDelegate, new object[] { message });
              }
  
          }
  
      }
  </code></pre>
  
  <p>Any help would be greatly appreciated.  </p>
  
  <p>source -> <a href="http://lamahashim.blogspot.com/2009/06/using-c-udpclient-send-and-receive.html" rel="noreferrer">http://lamahashim.blogspot.com/2009/06/using-c-udpclient-send-and-receive.html</a></p>