Discussion:
IdMappedPortTCP multiple hosts and ports
(too old to reply)
Cesco
2005-12-01 17:21:29 UTC
Permalink
Hello,

Using the IdMappedPortTCP, I can't find a way to map a host and port based
on the incomming request?
I'm using Delphi 6 and Indy 9.

I have two services with different ports on the same server, build with
TidHttpServer
With different incoming request I want to go to the right service.

I thought I could use the TIdMappedPortTCP, but this component has just one
mappedport. I can't change then mappedport or mappedhost in the Onconnect
event, because the connection to the mappedhost is already maken in the
OnConnect event.

Any ideas?

regards,
Cesco
Remy Lebeau (TeamB)
2005-12-01 21:42:32 UTC
Permalink
Post by Cesco
Using the IdMappedPortTCP, I can't find a way to map
a host and port based on the incomming request?
TIdMappedPortTCP does not natively support that. The only oppurtunity you
have to manipulate the outbound connection is in the OnConnect event. This
event is triggered after the TIdMappedPortThread.OutboundClient property is
assigned a TIdTCPClient object but before Connect() is called on it. You
can read the initial request from there and then update the OutboundClient
accordingly.
Post by Cesco
I can't change then mappedport or mappedhost in the Onconnect event
No, you cannot. Nor should you. You can, however, change the Host and Port
of the TIdMappedPortThread.OutboundClient property. For example:

procedure TForm1.IdMappedPortTCP1Connect(AThread: TIdMappedPortThread);
begin
//...
with TIdTCPClient(AThread.OutboundClient) do
begin
Host := '...';
Port := ...;
end;
end;
Post by Cesco
because the connection to the mappedhost is already maken
in the OnConnect event.
No, it is not. The connection to the target host is established after the
OnConnect event handler exits.


Gambit

Loading...