Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Oct : Re: TIdTrivialFTPServer and multi-homed server?
| Subject: | Re: TIdTrivialFTPServer and multi-homed server? |
| Posted by: | "Remy Lebeau (TeamB)" (no.spam@no.spam.com) |
| Date: | Mon, 9 Oct 2006 10:53:00 |
"Philippe Auphelle" <pauphelle.No.Spam.Please@wanadoo.fr> wrote in message
news:452a7d7e@newsgroups.borland.com...
> For each LocalAddress, I do a Bindings.Add, allocate an
> Id_SOCK_DGRAM, Id_IPPROTO_UDP handle, set the
> SocketHandle.IP to its own local address (the port is the
> default one in the server object) and I call Bind().
That is the wrong way to use the Bindings. Do not call AllocateSocket() or
Bind() at all. The server does that for you automatically when the Active
property is set to true. All you have to do is set the IP and Port
properties and that is all. For example:
var
Addresses: TStrings;
I: Integer;
begin
IdTrivialFTPServer1.Active := False;
IdTrivialFTPServer1.Bindings.Clear;
Addresses := GStack.LocalAddresses;
for I := 0 to Addreses.Count do
IdTrivialFTPServer1.Bindings.Add.IP := Addresses[I];
IdTrivialFTPServer1.Active := True;
end;
> I don't see any way in OnReadFile to link the incoming binding to
> the sender of the incoming packet
Loop through the Bindings collection looking for the entry that has the
PeerIP and PeerPort that are specified in the PeerInfo parameter of the
OnReadFile event handler. With that said, however, you do not need access
to the Binding itself. Since the event handler does provide you with the
IP/Port of the remote client that is sending the file data, simply use those
values when tracking the client and sending any replies back to that client.
> I assume this is by design: the UDP server knows the binding that accepted
> the packet, and the IP of the caller. And again, that doesn't prevent Indy
from
> entering the OnReadFile event and answering when there's only one IP
around.
Correct.
> I didn't find any mention of anything else (but the use of Bindings) in
> the help file. Still, the presence of the Bindings property and
> GStack.LocalAddresses clearly indicates that the multi-homing
> situation has not been overlooked in Indy.
No, it has not been overlooked.
Gambit