title: udp client server in pascal / delphi calling bind twice using synapse library (blcksock)
body: <p>I know my way around C but I have existing code for a UDP client and server in Pascal using the synapse library. My questions are:<br>
  Client:<br>
   - is it a good way to connect() to broadcast (instead of sendto())?  </p>
  
  <p>Server:<br>
   - how is it possible to call bind() twice? (main question)<br>
   - why would you bind() to the senderIP?</p>
  
  <p>Regards </p>
  
  <p>EDIT:<br>
  To clarify how this code is used:<br>
  There are multiple clients which try to send datapackets to the server. After the first packet of any of the clients arrives at the server, the server will from then on only accept data from this first client. Clients and server run on different machines.  </p>
  
  <p>Client:  </p>
  
  <pre><code>UDPport:=TUDPblockSocket.Create;
  UDPport.EnableBroadcast(true);
  UDPport.Connect(cBroadcast,'1234');
  while (not EOF(DATAfile)) do begin
    read(DATAfile,DATApacket);
    with (DATApacket) do begin
      NCOMport.SendBuffer(Addr(DATApacket),SizeOf(DATApacket));
    end;
  end;
  </code></pre>
  
  <p>Server:</p>
  
  <pre><code>begin
    with TUDPblockSocket.Create do begin
      Bind(cAnyHost,'1234');
      AnyHost:=true;
      while (true) do begin
        if (WaitingData&gt;0) then begin
          repeat
            buffer:=RecvPacket(c_UDPtimeout);
          until (WaitingData&lt;=0);
          if (AnyHost) then begin
            SenderIP:=GetRemoteSinIP;
            Bind(SenderIP,'1234');
            AnyHost:=false;
          end else begin
            {extracting information out of the received data buffer}
          end;
        end;
      end;
      Free;
    end;
  end;
  </code></pre>
  
  <p>with:  </p>
  
  <pre><code>const  c_UDPtimeout  = 100;
  </code></pre>
  
  <p>Regards</p>