I have a webservice implemented on delphi xe2 using Indy 10 TidHttpServer working very well in a local area network.
The problem that I found is in a computer with 2 network cards, one a regular NIC that works fine, and the other one a virtual NIC that routes traffic to a x.25 line connected to the phone company for credit card processing.
If the server gets rebooted (and I they like to do that frequently) windows is mounting the virtual NIC first and my server gets bind to it somehow. I do not understand how it works at all.
I read on the documentation from indy that it should be binding to all ips, an should be listening for both networks. However that is not happening. I am basically using the default configuration, except for the port that is assigned to 8888.
Is there a way to exclude this nic from indy http server?
I am looking for an example if possible.
The local network is in the 192.* range, and the virtual nic is in 187.* range. Today to make it work I need to disable the virtual nic, load my server and then enable back again the virtual nic. Works fine. But if get rebooted, I need to do all that again.
You can bind your server to a specific card by manually adding and configuring a binding before activating the server. A basic example would be something like this:
uses IdSocketHandle;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
SHandle: TIdSocketHandle;
begin
TIdTCPServer1.Bindings.Clear; //make sure there's no other bindings
SHandle := IdTCPServer1.Bindings.Add;
SHandle.IP := '192.168.0.15';
SHandle.Port := 3748;
IdTCPServer1.Active := True;
end;
As you can see, the example is done using a TIdTCPServer
. It works for any TIdCustomTCPServer
descendant, including TIdHTTPServer
.