 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Luc Guest
|
Posted: Mon Apr 19, 2004 5:30 pm Post subject: one pc, multiple connections |
|
|
Hi everyone,
I have a cable connection to the internet and at the same time I can run a
phone connection to connect to the internet.
The phone connection is needed for a smtp program, sending email.
When the phone connection is on, it seem that all other programs run by
that phone connection.
I would like to run the dnsresolver to get the mx-record by the cable
connenction, on the same PC.
How to do?
tx
Luc.
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Mon Apr 19, 2004 6:30 pm Post subject: Re: one pc, multiple connections |
|
|
"Luc" <ldee (AT) pandora (DOT) be> wrote
| Quote: | I would like to run the dnsresolver to get the mx-record
by the cable connenction, on the same PC.
|
Every socket connection is bound to a specific hardware adapter during its
operation. The cable modem has its own network adapter installed in the
Control panel, as so does the phone modem (or should anyway). When you
create a new socket, simply bind() it to the desired adapter first before
you open the connection. Then it will operation on the hardware that is
attached to that adapter. How you actually do that depends on how you are
woking with sockets in the first place.
Gambit
|
|
| Back to top |
|
 |
Luc Guest
|
Posted: Mon Apr 19, 2004 8:44 pm Post subject: Re: one pc, multiple connections |
|
|
tx for your quick answer
I got the idea.
For now, I simply has on my form a TidDNSResolver and ask for a mx-record.
I suppose I should work with somenthing else, starting from a socket, and
bind() this to the network adaptor.
Or perhaps override some procedure from the dnsResolver component.
I try to find it, as some sample code would of course be easy...
tx anayway , pointing me in the good direction.
Luc.
"Remy Lebeau (TeamB)" <gambit47.no.spam (AT) no (DOT) spam.yahoo.com> schreef in
bericht news:40841d56$1 (AT) newsgroups (DOT) borland.com...
| Quote: |
"Luc" <ldee (AT) pandora (DOT) be> wrote in message
news:40840c98 (AT) newsgroups (DOT) borland.com...
I would like to run the dnsresolver to get the mx-record
by the cable connenction, on the same PC.
Every socket connection is bound to a specific hardware adapter during its
operation. The cable modem has its own network adapter installed in the
Control panel, as so does the phone modem (or should anyway). When you
create a new socket, simply bind() it to the desired adapter first before
you open the connection. Then it will operation on the hardware that is
attached to that adapter. How you actually do that depends on how you are
woking with sockets in the first place.
Gambit
|
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Mon Apr 19, 2004 11:55 pm Post subject: Re: one pc, multiple connections |
|
|
"Luc" <ldee (AT) pandora (DOT) be> wrote
| Quote: | For now, I simply has on my form a TidDNSResolver and ask for a mx-record.
|
Then update the IP of the Binding property prior to performing the query.
| Quote: | I suppose I should work with somenthing else, starting
from a socket, and bind() this to the network adaptor.
|
That is not necessary. Indy natively supports socket bindings.
Gambit
|
|
| Back to top |
|
 |
Luc Guest
|
Posted: Tue Apr 20, 2004 8:59 am Post subject: Re: one pc, multiple connections |
|
|
sorry, but I do not find the method to bind the TidDNSResolver to the
correct IP adres.
and, how do I find on my computer the correct IPadres to bind to.
and in the newsgoups I also read a portnumber is involved??
tx in advance for helping me
Luc.
"Remy Lebeau (TeamB)" <gambit47.no.spam (AT) no (DOT) spam.yahoo.com> schreef in
bericht news:4084685b$1 (AT) newsgroups (DOT) borland.com...
| Quote: |
"Luc" <ldee (AT) pandora (DOT) be> wrote in message
news:408439f2 (AT) newsgroups (DOT) borland.com...
For now, I simply has on my form a TidDNSResolver and ask for a
mx-record.
Then update the IP of the Binding property prior to performing the query.
I suppose I should work with somenthing else, starting
from a socket, and bind() this to the network adaptor.
That is not necessary. Indy natively supports socket bindings.
Gambit
|
|
|
| Back to top |
|
 |
Luc Guest
|
Posted: Tue Apr 20, 2004 12:40 pm Post subject: Re: one pc, multiple connections |
|
|
what is wrong?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdUDPBase, IdUDPClient,
IdDNSResolver,idStack,idglobal;
type
TForm1 = class(TForm)
Button1: TButton;
peerIP: TEdit;
Memo1: TMemo;
ListBox1: TListBox;
dns: TIdDNSResolver;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
mxServerIndex: integer;
begin
memo1.Clear;
dns.Host:= peerIP.Text;
dns.Port:= 53;
dns.QueryRecords := [qtMX];
dns.Binding.SetPeer(peerIP.Text,53);
with dns do
begin
try
Resolve('hotmail.com');
for mxServerIndex:=0 to QueryResult.Count-1 do
begin
memo1.Lines.Add(QueryResult.Items[mxServerIndex].Name);
memo1.Lines.Add(QueryResult.Items[mxServerIndex].RData);
memo1.Lines.Add(inttostr(tmxrecord(QueryResult.Items[mxServerIndex]).Prefere
nce));
memo1.Lines.Add(tmxrecord(QueryResult.Items[mxServerIndex]).ExchangeServer);
end;
except
on e:exception do ShowMessage('Resolve attempt failed:
'+e.message);
end;
end;
dns.Free;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
peerIP.Text:= gstack.LocalAddress;
listbox1.Items := gstack.LocalAddresses;
end;
end.
this program gives error: 10054, connection reset by peer.
when I change dns.host:= '212.100.160.52' - memo1 is populated with answers.
I have in listbox1 the 2 IP-adresses for my 2 connections (192.168.03.7 and
62.4.198.198)
the line
dns.Binding.SetPeer(peerIP.Text,53);
changing to one or the other, the query allways run over the phone
connection
tx for helping
Luc.
"Remy Lebeau (TeamB)" <gambit47.no.spam (AT) no (DOT) spam.yahoo.com> schreef in
bericht news:40841d56$1 (AT) newsgroups (DOT) borland.com...
| Quote: |
"Luc" <ldee (AT) pandora (DOT) be> wrote in message
news:40840c98 (AT) newsgroups (DOT) borland.com...
I would like to run the dnsresolver to get the mx-record
by the cable connenction, on the same PC.
Every socket connection is bound to a specific hardware adapter during its
operation. The cable modem has its own network adapter installed in the
Control panel, as so does the phone modem (or should anyway). When you
create a new socket, simply bind() it to the desired adapter first before
you open the connection. Then it will operation on the hardware that is
attached to that adapter. How you actually do that depends on how you are
woking with sockets in the first place.
Gambit
|
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue Apr 20, 2004 7:55 pm Post subject: Re: one pc, multiple connections |
|
|
"Luc" <ldee (AT) pandora (DOT) be> wrote
| Quote: | sorry, but I do not find the method to bind the
TidDNSResolver to the correct IP adres.
|
I already told you exactly how to do it - update the Bindng.IP property
before performing the query. For example:
IdDNSResolver.Active := False;
IdDNSResolver.Binding.IP := 'the desired IP to bind to';
IdDNSResolver.Resolve(...);
| Quote: | and, how do I find on my computer the correct IPadres to bind to.
|
That is your own responsibility to determine beforehand. Either provide a
UI input field for the user to fill in the adapter's IP, or else try to
obtain it programmably by obtaining the adapter's IP address directly. Look
at the Win32 API GetAdaptersInfo() function, for instance.
| Quote: | and in the newsgoups I also read a portnumber is involved??
|
Not for DNS, it is a fixed port number that TIdDNSResolver is already using.
Gambit
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue Apr 20, 2004 8:02 pm Post subject: Re: one pc, multiple connections |
|
|
"Luc" <ldee (AT) pandora (DOT) be> wrote
| Quote: | dns.Host:= peerIP.Text;
|
You do not need to set the Port. It is already set automatically.
| Quote: | dns.Binding.SetPeer(peerIP.Text,53);
|
Do not call SetPeer() at all. It is called automatically when the
connection is actually established.
| Quote: | peerIP.Text:= gstack.LocalAddress;
|
That is not correct. You are telling TIdDNSResolver that your local machine
is the DNS server to connect to. You need to use a real DNS server instead,
such as the one provided by your ISP.
| Quote: | this program gives error: 10054, connection reset by peer.
|
As well it should. You used the wrong IP/Host value, thus TIdDNSResolver
tried to connect to the wrong server.
| Quote: | when I change dns.host:= '212.100.160.52' - memo1
is populated with answers.
|
As well it should. That is a real DNS server IP.
| Quote: | the line
dns.Binding.SetPeer(peerIP.Text,53);
changing to one or the other, the query allways run over the phone
connection
|
That is not the way to bind a socket at all. The only thing SetPeer() does
is updates the PeerIP and PeerPort properties, nothing more. They have
nothing to do with the actual socket at all. As I already told you earlier,
you should be using the Binding's IP property instead:
dns.Binding.IP := 'the local IP that you want to bind to';
Gambit
|
|
| Back to top |
|
 |
Luc Guest
|
Posted: Wed Apr 21, 2004 12:05 pm Post subject: Re: one pc, multiple connections |
|
|
"Remy Lebeau (TeamB)" <gambit47.no.spam (AT) no (DOT) spam.yahoo.com> schreef in
bericht news:408581a7$1 (AT) newsgroups (DOT) borland.com...
| Quote: | IdDNSResolver.Active := False;
IdDNSResolver.Binding.IP := 'the desired IP to bind to';
IdDNSResolver.Resolve(...);
the desired IP to bind to
That is your own responsibility to determine beforehand. Either provide a
UI input field for the user to fill in the adapter's IP, or else try to
obtain it programmably by obtaining the adapter's IP address directly.
Look
at the Win32 API GetAdaptersInfo() function, for instance.
|
I use a listbox to display the ip's
listbox1.Items := gstack.LocalAddresses;
Setting IdDNSResolver.Binding.IP := to the first (192.168.0.4) or to the
phone (62.4.199.16) or to a random (33.33.33.33)
it all make no difference, always retrieve over the phone connection
Sorry Remy, this make no differerence.
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Wed Apr 21, 2004 5:32 pm Post subject: Re: one pc, multiple connections |
|
|
"Luc" <ldee (AT) pandora (DOT) be> wrote
| Quote: | I use a listbox to display the ip's
listbox1.Items := gstack.LocalAddresses;
Setting IdDNSResolver.Binding.IP := to the first (192.168.0.4)
or to the phone (62.4.199.16) or to a random (33.33.33.33)
it all make no difference, always retrieve over the phone connection
|
Please show your actual code.
Gambit
|
|
| Back to top |
|
 |
Luc Guest
|
Posted: Wed Apr 21, 2004 10:41 pm Post subject: Re: one pc, multiple connections |
|
|
this smaller version only uses the telephone connenction, regardless what I
put in the bindingIP edit box.
-------------------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdUDPBase, IdUDPClient,
IdDNSResolver,idStack,idglobal;
type
TForm1 = class(TForm)
Button1: TButton;
bindingIP: TEdit;
Memo1: TMemo;
ListBox1: TListBox;
dns: TIdDNSResolver;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
mxServerIndex: integer;
begin
memo1.Clear;
dns.Host:= '212.100.160.52';
dns.QueryRecords := [qtMX];
with dns do
begin
try
Active := False;
binding.IP := bindingIP.Text;
Resolve('hotmail.com');
for mxServerIndex:=0 to QueryResult.Count-1 do
begin
memo1.Lines.Add(QueryResult.Items[mxServerIndex].Name);
memo1.Lines.Add(QueryResult.Items[mxServerIndex].RData);
memo1.Lines.Add(inttostr(tmxrecord(QueryResult.Items[mxServerIndex]).Prefere
nce));
memo1.Lines.Add(tmxrecord(QueryResult.Items[mxServerIndex]).ExchangeServer);
end;
except
on e:exception do ShowMessage('Resolve attempt failed:
'+e.message);
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
bindingIP.Text:= gstack.LocalAddress;
listbox1.Items := gstack.LocalAddresses;
end;
end.
"Remy Lebeau (TeamB)" <gambit47.no.spam (AT) no (DOT) spam.yahoo.com> schreef in
bericht news:4086b197 (AT) newsgroups (DOT) borland.com...
| Quote: |
"Luc" <ldee (AT) pandora (DOT) be> wrote in message
news:40866376 (AT) newsgroups (DOT) borland.com...
I use a listbox to display the ip's
listbox1.Items := gstack.LocalAddresses;
Setting IdDNSResolver.Binding.IP := to the first (192.168.0.4)
or to the phone (62.4.199.16) or to a random (33.33.33.33)
it all make no difference, always retrieve over the phone connection
Please show your actual code.
Gambit
|
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Wed Apr 21, 2004 11:04 pm Post subject: Re: one pc, multiple connections |
|
|
"Luc" <ldee (AT) pandora (DOT) be> wrote
| Quote: | Active := False;
binding.IP := bindingIP.Text;
Resolve('hotmail.com');
|
Try calling Bind() before calling Resolve():
Active := False;
Binding.IP := bindingIP.Text;
Binding.Bind; // <-- here
Resolve('hotmail.com');
I would have figured TIdUDPBase/Client would have done that automatically,
but apparently it doesn't so try calling it manually.
| Quote: | procedure TForm1.FormCreate(Sender: TObject);
begin
bindingIP.Text:= gstack.LocalAddress;
listbox1.Items := gstack.LocalAddresses;
end;
|
Did you verify that the LocalAddress even belongs to the cable connection
and not the phone connection to begin with? They are each going to get a
different IP. The LocalAddress property only returns the first IP that the
OS reports, and as such it does not guarantee which IP will be the one
reported when multiple IPs are available at the time.
If the IP turns out not to actually belong to the cable connection, then are
you providing a way to get a value from the ListBox into the Edit box if the
user wants to use a different address? If so, that code was not included in
your example.
Gambit
|
|
| Back to top |
|
 |
Luc Guest
|
Posted: Thu Apr 22, 2004 12:03 am Post subject: Re: one pc, multiple connections |
|
|
tx Remy, we are getting closer, I hope.
I inserted the line Binding.Bind;
and .... the program hangs
relaunch, binding to the telephone IP, and we get the mxrecord
when I shut down the telephone connection and relaunch, no problem, mxrecord
is retrieved from cable.
so, the line Binding.Bind;, changes something important.
tracing down to IdStackWindows.pas
function TIdStackWindows.WSSelect(Aread, AWrite, AErrors: TList; ATimeout:
Integer): Integer;
..
..
Result := Select(0, @FDRead, .... <--hangs.
PC = XP Pro
connected to internet with cable connection behind router.
and with telephone modem
ps.
this programs is only ment to test the binding, and kept as small as
possible.
In the listbox, I get the 2 adresses
192.168.0.4 (ip adres given by the router to the pc)
62.4.xx.xx (changing ip adres by dialing in)
"Remy Lebeau (TeamB)"
bericht news:4087010b$1 (AT) newsgroups (DOT) borland.com...
| Quote: |
"Luc" <ldee (AT) pandora (DOT) be> wrote in message
news:4086f8ad$1 (AT) newsgroups (DOT) borland.com...
Active := False;
binding.IP := bindingIP.Text;
Resolve('hotmail.com');
Try calling Bind() before calling Resolve():
Active := False;
Binding.IP := bindingIP.Text;
Binding.Bind; // <-- here
Resolve('hotmail.com');
I would have figured TIdUDPBase/Client would have done that automatically,
but apparently it doesn't so try calling it manually.
procedure TForm1.FormCreate(Sender: TObject);
begin
bindingIP.Text:= gstack.LocalAddress;
listbox1.Items := gstack.LocalAddresses;
end;
Did you verify that the LocalAddress even belongs to the cable connection
and not the phone connection to begin with? They are each going to get a
different IP. The LocalAddress property only returns the first IP that
the
OS reports, and as such it does not guarantee which IP will be the one
reported when multiple IPs are available at the time.
If the IP turns out not to actually belong to the cable connection, then
are
you providing a way to get a value from the ListBox into the Edit box if
the
user wants to use a different address? If so, that code was not included
in
your example.
Gambit
|
|
|
| Back to top |
|
 |
Luc Guest
|
Posted: Thu Apr 22, 2004 11:03 pm Post subject: Re: one pc, multiple connections |
|
|
perhaps i should test the binding with a other component, to find out if
this is some hardware problem.
I would appreciate some example code.
Luc
"Luc" <ldee (AT) pandora (DOT) be> schreef in bericht
news:40870bb8$1 (AT) newsgroups (DOT) borland.com...
| Quote: | tx Remy, we are getting closer, I hope.
I inserted the line Binding.Bind;
and .... the program hangs
relaunch, binding to the telephone IP, and we get the mxrecord
when I shut down the telephone connection and relaunch, no problem,
mxrecord
is retrieved from cable.
so, the line Binding.Bind;, changes something important.
tracing down to IdStackWindows.pas
function TIdStackWindows.WSSelect(Aread, AWrite, AErrors: TList; ATimeout:
Integer): Integer;
.
.
Result := Select(0, @FDRead, .... <--hangs.
PC = XP Pro
connected to internet with cable connection behind router.
and with telephone modem
ps.
this programs is only ment to test the binding, and kept as small as
possible.
In the listbox, I get the 2 adresses
192.168.0.4 (ip adres given by the router to the pc)
62.4.xx.xx (changing ip adres by dialing in)
"Remy Lebeau (TeamB)"
bericht news:4087010b$1 (AT) newsgroups (DOT) borland.com...
"Luc" <ldee (AT) pandora (DOT) be> wrote in message
news:4086f8ad$1 (AT) newsgroups (DOT) borland.com...
Active := False;
binding.IP := bindingIP.Text;
Resolve('hotmail.com');
Try calling Bind() before calling Resolve():
Active := False;
Binding.IP := bindingIP.Text;
Binding.Bind; // <-- here
Resolve('hotmail.com');
I would have figured TIdUDPBase/Client would have done that
automatically,
but apparently it doesn't so try calling it manually.
procedure TForm1.FormCreate(Sender: TObject);
begin
bindingIP.Text:= gstack.LocalAddress;
listbox1.Items := gstack.LocalAddresses;
end;
Did you verify that the LocalAddress even belongs to the cable
connection
and not the phone connection to begin with? They are each going to get
a
different IP. The LocalAddress property only returns the first IP that
the
OS reports, and as such it does not guarantee which IP will be the one
reported when multiple IPs are available at the time.
If the IP turns out not to actually belong to the cable connection, then
are
you providing a way to get a value from the ListBox into the Edit box if
the
user wants to use a different address? If so, that code was not
included
in
your example.
Gambit
|
|
|
| Back to top |
|
 |
Milan Guest
|
Posted: Mon Apr 26, 2004 8:42 am Post subject: Re: one pc, multiple connections |
|
|
Don't you see this guy is a spammer??
Sending mail over a dial-up with Indy, while having a cable connection for
MX records..
Supporting people in forums is great, but supporting spammers sucks.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|