Re: TIdUDPBase GetBinding

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

Remy Lebeau (Indy Team) wrote:
> "Ulrich Doewich" <w…@cares.com> wrote in message
> news:586DD6A9FE35E340w…@cares.com...
>
>> 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)
  private
    FUDP: TIdUDPClient; // socket to use for all UDP communications
    ...

  FUDP := TIdUDPClient.Create; // the socket to use for all UDP
transmissions
  FUDP.BoundPortMin := ASourcePortLow; // port range, low mark
  FUDP.BoundPortMax := ASourcePortHigh; // port range, high mark
  try
    FUDP.BoundPort := 0; // make sure we are using the values of
ClientPortMin and ClientPortMax
    FUDP.Connect; // attempt to find an unused port
  except
    on E: EIdCanNotBindPortInRange do begin // handle all ports-in-use
exception
      FErrCode := EC_COMM;
      FErrMessage := 'All assigned ports are in use.';
      Result := FErrCode;
      Exit;
    end;
  end;
  ...
  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;

to
    property BoundPortMin: TIdPort read FBoundPortMin write FBoundPortMin;

Cheers,
Ulrich

Replies

None

In response to

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