Re: TIdUDPBase GetBinding

Giganews Newsgroups
Subject: Re: TIdUDPBase GetBinding
Posted by:  Ulrich Doewich (w…
Date: Wed, 19 Sep 2007

Remy Lebeau (Indy Team) wrote:
> "Ulrich Doewich" <w…> wrote in message
> news:586DD6A9FE35E340w…
>> I'm trying to compile my application with the latest Indy build,
>> however at some point GetBinding in TIdUDPBase seems
>> to have been made abstract...
> What is the actual error you are getting?  What does your code look like?

I don't recall the exact message, but it was basically to the effect
that GetBinding was defined abstract and the routine wasn't there.

> You should not be instantiating TIdUDPBase directly.  Use TIdUDPClient or
> TIdUDPServer instead, which both override GetBinding().

So far, I was using an instance of TIdUDPBase and provided my own code
to do the client/server tasks.

I'm now trying to convert the code to use the Client and Server
descendants instead...

Here are the relevant bits of my code:

  UdpCommObject = class(TObject)
    FUDP: TIdUDPClient; // socket to use for all UDP communications

  FUDP := TIdUDPClient.Create; // the socket to use for all UDP
  FUDP.BoundPortMin := ASourcePortLow; // port range, low mark
  FUDP.BoundPortMax := ASourcePortHigh; // port range, high mark
    FUDP.BoundPort := 0; // make sure we are using the values of
ClientPortMin and ClientPortMax
    FUDP.Connect; // attempt to find an unused port
    on E: EIdCanNotBindPortInRange do begin // handle all ports-in-use
      FErrCode := EC_COMM;
      FErrMessage := 'All assigned ports are in use.';
      Result := FErrCode;
  FUDP.Send(FDestinationIp, FDestinationPort, ADataToSend); // send the
UDP packet

If I step through this (and the Indy code), I can see that eventually
IdWinsock2.SendTo is called in TIdStackWindows.WSSendTo and LBytesOut
matches the output buffer length - however, nothing gets to the other
side and a transcript with WireShark shows no UDP trasmission... any
ideas what could be wrong?

BTW: I had to apply a small fix to IdUDPClient.pas:

line 130 should be changed from

    property BoundPortMin: TIdPort read FBoundPortMin write FBoundPortMax;

    property BoundPortMin: TIdPort read FBoundPortMin write FBoundPortMin;




In response to

Re: TIdUDPBase GetBinding posted by Remy Lebeau \(Indy Team\) on Tue, 18 Sep 2007