Thread View: borland.public.cppbuilder.nativeapi
5 messages
5 total messages
Started by Robert G. Hoover
Thu, 10 May 2007 16:29
TClientSocket::LocalAddress
Author: Robert G. Hoover
Date: Thu, 10 May 2007 16:29
Date: Thu, 10 May 2007 16:29
29 lines
1936 bytes
1936 bytes
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";
Re: TClientSocket::LocalAddress
Author: Remy Lebeau (TeamB)
Date: Thu, 10 May 2007 18:04
Date: Thu, 10 May 2007 18:04
35 lines
2131 bytes
2131 bytes
"Robert G. Hoover" <not.a.real.address@anywhere.sorry> wrote in message news:46434854$1@newsgroups.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
Re: TClientSocket::LocalAddress
Author: Robert G. Hoover
Date: Fri, 11 May 2007 11:26
Date: Fri, 11 May 2007 11:26
55 lines
3204 bytes
3204 bytes
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: > "Robert G. Hoover" <not.a.real.address@anywhere.sorry> wrote in > message news:46434854$1@newsgroups.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 > >
Re: TClientSocket::LocalAddress
Author: Remy Lebeau (TeamB)
Date: Fri, 11 May 2007 16:54
Date: Fri, 11 May 2007 16:54
35 lines
2195 bytes
2195 bytes
"Robert G. Hoover" <not.a.real.address@anywhere.sorry> wrote in message news:46445305$1@newsgroups.borland.com... > 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. > 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. > 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. > 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
Re: TClientSocket::LocalAddress
Author: Robert G. Hoover
Date: Fri, 15 Jun 2007 14:42
Date: Fri, 15 Jun 2007 14:42
24 lines
1919 bytes
1919 bytes
Just to follow up.... I finally got around to tracking down the connection problem. I was connecting to my local AntiVirus software who was scanning outgoing SMTP data, thus 127.0.0.1 indicated a local host rather than the remote company server. I disabled the outgoing SMTP check and it passes right through now. Thanks Remy for the help... Rob Remy Lebeau (TeamB) wrote: > Do not make assumptions. You need to find out exactly what you are > really connecting to. > >> 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.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads