 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Robert G. Hoover Guest
|
Posted: Thu May 10, 2007 9:29 pm Post subject: TClientSocket::LocalAddress |
|
|
Hi,
I'm using a TClientSocket to connect to my company's SMTP server to send an
automated email message (for internal use only - NOT SPAM) over port 25. I'm
identifying myself to the server as Socket->LocalHost
ehlo [192.168.0.109]
which seems to work on my laptop where LocalAddress = 192.168.0.109 and does not
work on my desktop where LocalAddress = 127.0.0.1. Neither of these is ideal as
I think the SMTP server wants my "worldview" IP address which is something like
109.76.35.22. How can I determine my actual IP address from inside this
TClientSocket object?
Thanks,
Rob
---------------------------------------------------
// compile message
AnsiString MessageContents = "ehlo [" + Socket->LocalAddress + "]\n"
+ "mail from:" + EmailSender->Text + "\n"
+ "rcpt to:" + EmailRecipient->Text + "\n"
+ "data\n"
+ "from:" + EmailFrom->Text + "\n"
+ "to:" + EmailTo->Text + "\n"
+ "subject:" + EmailSubject->Text + "\n"; |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Thu May 10, 2007 11:04 pm Post subject: Re: TClientSocket::LocalAddress |
|
|
"Robert G. Hoover" <not.a.real.address (AT) anywhere (DOT) sorry> wrote in
message news:46434854$1 (AT) newsgroups (DOT) borland.com...
| Quote: | I'm identifying myself to the server as Socket->LocalHost
ehlo [192.168.0.109]
which seems to work on my laptop where LocalAddress = 192.168.0.109
and does not work on my desktop where LocalAddress = 127.0.0.1.
|
The LocalAddress can only be 127.0.0.1 if you had connected to
"localhost" when connecting the socket. Is your server running on the
same desktop machine as your client program?
| Quote: | Neither of these is ideal as I think the SMTP server wants my
"worldview" IP address which is something like 109.76.35.22.
|
Actually, you should be sending your machine name, not your IP
address.
| Quote: | How can I determine my actual IP address from inside this
TClientSocket object? |
If you are directly connected to the Internet, such that your modem is
physically plugged into your machine, then you can use
GetAdaptersInfo() to get the IP address from the desired NIC, which
should be the same IP that LocalAddress returns. But if you are
getting your Internet access through a router or gateway, then you
will have to query an external source, such as
http://iplookup.flashfxp.com or similar site, to get your public IP
address.
Gambit |
|
| Back to top |
|
 |
Robert G. Hoover Guest
|
Posted: Fri May 11, 2007 4:26 pm Post subject: Re: TClientSocket::LocalAddress |
|
|
Hi Remy,
Great stuff!!! (as usual)
Well, it seems that I am not connecting to whom I should be. I am getting a
partial response from someone, whom I must assume is the company SMTP server
(not on my computer). I get the standard communication stuff. "250 Ok." So I
must be talking to the right computer with the right protocol. Yet, my
Socket->LocalAddress = 127.0.0.1. It sure doesn't sound right. I've got a few
other programs running.... Skype, VNC Server, AVAST AntiVirus. I'm going to
knock them down 1 by 1 to see which one might be causing the communication
breakdown.
Thanks for the help! The iplookup addy will come in handy!
Rob
Remy Lebeau (TeamB) wrote:
| Quote: | "Robert G. Hoover" <not.a.real.address (AT) anywhere (DOT) sorry> wrote in
message news:46434854$1 (AT) newsgroups (DOT) borland.com...
I'm identifying myself to the server as Socket->LocalHost
ehlo [192.168.0.109]
which seems to work on my laptop where LocalAddress = 192.168.0.109
and does not work on my desktop where LocalAddress = 127.0.0.1.
The LocalAddress can only be 127.0.0.1 if you had connected to
"localhost" when connecting the socket. Is your server running on the
same desktop machine as your client program?
Neither of these is ideal as I think the SMTP server wants my
"worldview" IP address which is something like 109.76.35.22.
Actually, you should be sending your machine name, not your IP
address.
How can I determine my actual IP address from inside this
TClientSocket object?
If you are directly connected to the Internet, such that your modem is
physically plugged into your machine, then you can use
GetAdaptersInfo() to get the IP address from the desired NIC, which
should be the same IP that LocalAddress returns. But if you are
getting your Internet access through a router or gateway, then you
will have to query an external source, such as
http://iplookup.flashfxp.com or similar site, to get your public IP
address.
Gambit
|
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Fri May 11, 2007 9:54 pm Post subject: Re: TClientSocket::LocalAddress |
|
|
"Robert G. Hoover" <not.a.real.address (AT) anywhere (DOT) sorry> wrote in
message news:46445305$1 (AT) newsgroups (DOT) borland.com...
| Quote: | I am getting a partial response from someone, whom I must assume
is the company SMTP server (not on my computer).
|
Do not make assumptions. You need to find out exactly what you are
really connecting to.
| Quote: | I get the standard communication stuff. "250 Ok." So I must be
talking
to the right computer with the right protocol.
|
Not necessarily. A lot of internet protocols use similar response
syntaxes. You shouls use a packet sniffer, such as Ethereal, to see
the raw packet data. Only then can you really verify what you are
actually connected to.
| Quote: | Yet, my Socket->LocalAddress = 127.0.0.1.
|
As I told you earlier, that can only occur if you are connected to a
server on the local machine only. If you were really connected to an
external server on the network, the LocalAddress would not be
reporting the local loopback address.
| Quote: | I've got a few other programs running.... Skype, VNC Server, AVAST
AntiVirus. I'm going to knock them down 1 by 1 to see which one
might be causing the communication breakdown.
|
It might be useful if you could show your actual TClientSocket code
here. You are probably just setting it up wrong.
Gambit |
|
| 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
|
|