Delphi and Kylix

Moderators: pritaeas
Number of threads: 7244
Number of posts: 19051

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
How to id IP address - LAN and Internet - using TClientSocket and TSer Posted by GarryPaxton on 3 Dec 2003 at 12:10 PM
Hi, I used to have IP addresses explicitly defined on my LAN, and my apps communicated ok using TClientSocket and TServerSocket (IP address was hard-coded).

Now that I have changed this to obtain an IP address automatically, I need to find out my IP address at run time for my apps to communicate, over the LAN and over the internet.

a) How can I discover my IP address, please ?
b) Does it matter that I am using a broadband connection ? I wish to use my app on dial up connections too

I'm using Delphi 6.

Many, Many thanx - Gazza (newbie)

Report
Re: How to id IP address - LAN and Internet - using TClientSocket and Posted by Manning on 3 Dec 2003 at 12:35 PM
: Hi, I used to have IP addresses explicitly defined on my LAN, and my apps communicated ok using TClientSocket and TServerSocket (IP address was hard-coded).
:
: Now that I have changed this to obtain an IP address automatically, I need to find out my IP address at run time for my apps to communicate, over the LAN and over the internet.
:
: a) How can I discover my IP address, please ?
: b) Does it matter that I am using a broadband connection ? I wish to use my app on dial up connections too
:
: I'm using Delphi 6.

What exactly is it you are trying to do? Do you want the client to find the IP address of the server? That's not really practical. You have to tell a client where to connect to, it can't just pull IP addresses out of a hat.

Is that what you're asking? If not, please explain with better detail.
Report
Re: How to id IP address - LAN and Internet - using TClientSocket and Posted by GarryPaxton on 3 Dec 2003 at 2:21 PM
: : Hi, I used to have IP addresses explicitly defined on my LAN, and my apps communicated ok using TClientSocket and TServerSocket (IP address was hard-coded).
: :
: : Now that I have changed this to obtain an IP address automatically, I need to find out my IP address at run time for my apps to communicate, over the LAN and over the internet.
: :
: : a) How can I discover my IP address, please ?
: : b) Does it matter that I am using a broadband connection ? I wish to use my app on dial up connections too
: :
: : I'm using Delphi 6.
:
: What exactly is it you are trying to do? Do you want the client to find the IP address of the server? That's not really practical. You have to tell a client where to connect to, it can't just pull IP addresses out of a hat.
:
: Is that what you're asking? If not, please explain with better detail.
:
Well, basically I'd like two PCs to communicate. The apps are simply passing strings back and forth.

That's fairly easy across my home LAN where I can set IP addresses explicitly. In the client app, I can hardcode the IP address of the server, and while the server is in 'listening' mode, set the ClientSocket.Host of any client app to the pre-set IPaddr of the Server. Hey presto, connected.

But to talk across the internet seems a more complex task. This is because the IPaddr of the server is no longer constant, as it's determined by my ISP. Consequently, my client apps cannot have the server IP address 'hard-coded' when use on the net.

I don't really understand how to approach the problem, but have guessed that I can probably set up another app somewhere else, for example, on my website, which collects the current IP address of any of my apps dotted around the internet - that's the first place they check in to confirm their online presence. Client apps will consult this table of IP addresses to find out where the server(s) are. So my starting point was...How do I find out the IP address that has been allocated to me by my ISP today ? And start from there. Its difficult to define the problem more explicity as it is more an issue of 'how do I approach this' ? Maybe my appraoch is totally wrong. thanx for advice on way forward. Gazza
Report
Re: How to id IP address - LAN and Internet - using TClientSocket and Posted by Perran on 3 Dec 2003 at 2:48 PM
: : : Hi, I used to have IP addresses explicitly defined on my LAN, and my apps communicated ok using TClientSocket and TServerSocket (IP address was hard-coded).
: : :
: : : Now that I have changed this to obtain an IP address automatically, I need to find out my IP address at run time for my apps to communicate, over the LAN and over the internet.
: : :
: : : a) How can I discover my IP address, please ?
: : : b) Does it matter that I am using a broadband connection ? I wish to use my app on dial up connections too
: : :
: : : I'm using Delphi 6.
: :
: : What exactly is it you are trying to do? Do you want the client to find the IP address of the server? That's not really practical. You have to tell a client where to connect to, it can't just pull IP addresses out of a hat.
: :
: : Is that what you're asking? If not, please explain with better detail.
: :
: Well, basically I'd like two PCs to communicate. The apps are simply passing strings back and forth.
:
: That's fairly easy across my home LAN where I can set IP addresses explicitly. In the client app, I can hardcode the IP address of the server, and while the server is in 'listening' mode, set the ClientSocket.Host of any client app to the pre-set IPaddr of the Server. Hey presto, connected.
:
: But to talk across the internet seems a more complex task. This is because the IPaddr of the server is no longer constant, as it's determined by my ISP. Consequently, my client apps cannot have the server IP address 'hard-coded' when use on the net.
:
: I don't really understand how to approach the problem, but have guessed that I can probably set up another app somewhere else, for example, on my website, which collects the current IP address of any of my apps dotted around the internet - that's the first place they check in to confirm their online presence. Client apps will consult this table of IP addresses to find out where the server(s) are. So my starting point was...How do I find out the IP address that has been allocated to me by my ISP today ? And start from there. Its difficult to define the problem more explicity as it is more an issue of 'how do I approach this' ? Maybe my appraoch is totally wrong. thanx for advice on way forward. Gazza
:
Are you sure that the IP address of the server is not constant? It should be. If your going to use the same server all the time, determine the server address by pinging it and hard-code it in. At least you could do that for testing. I use D6 and have those Indy components. There's a DNS name resolver component that you could use. It might be worth poking around in the Internet Standards documents.
Report
Re: How to id IP address - LAN and Internet - using TClientSocket and Posted by Manning on 3 Dec 2003 at 4:53 PM
: : : Hi, I used to have IP addresses explicitly defined on my LAN, and my apps communicated ok using TClientSocket and TServerSocket (IP address was hard-coded).
: : :
: : : Now that I have changed this to obtain an IP address automatically, I need to find out my IP address at run time for my apps to communicate, over the LAN and over the internet.
: : :
: : : a) How can I discover my IP address, please ?
: : : b) Does it matter that I am using a broadband connection ? I wish to use my app on dial up connections too
: : :
: : : I'm using Delphi 6.
: :
: : What exactly is it you are trying to do? Do you want the client to find the IP address of the server? That's not really practical. You have to tell a client where to connect to, it can't just pull IP addresses out of a hat.
: :
: : Is that what you're asking? If not, please explain with better detail.
: :
: Well, basically I'd like two PCs to communicate. The apps are simply passing strings back and forth.
:
: That's fairly easy across my home LAN where I can set IP addresses explicitly. In the client app, I can hardcode the IP address of the server, and while the server is in 'listening' mode, set the ClientSocket.Host of any client app to the pre-set IPaddr of the Server. Hey presto, connected.
:
: But to talk across the internet seems a more complex task. This is because the IPaddr of the server is no longer constant, as it's determined by my ISP. Consequently, my client apps cannot have the server IP address 'hard-coded' when use on the net.
:
: I don't really understand how to approach the problem, but have guessed that I can probably set up another app somewhere else, for example, on my website, which collects the current IP address of any of my apps dotted around the internet - that's the first place they check in to confirm their online presence. Client apps will consult this table of IP addresses to find out where the server(s) are. So my starting point was...How do I find out the IP address that has been allocated to me by my ISP today ? And start from there. Its difficult to define the problem more explicity as it is more an issue of 'how do I approach this' ? Maybe my appraoch is totally wrong. thanx for advice on way forward. Gazza
:


Okay, so you do want to do what I thought. It sounds like you need to sign up with a Dynamic DNS service. A good one I used to use is available at http://www.myip.us.
Report
Re: How to id IP address - LAN and Internet - using TClientSocket and Posted by GarryPaxton on 4 Dec 2003 at 2:37 AM
: : : : Hi, I used to have IP addresses explicitly defined on my LAN, and my apps communicated ok using TClientSocket and TServerSocket (IP address was hard-coded).
: : : :
: : : : Now that I have changed this to obtain an IP address automatically, I need to find out my IP address at run time for my apps to communicate, over the LAN and over the internet.
: : : :
: : : : a) How can I discover my IP address, please ?
: : : : b) Does it matter that I am using a broadband connection ? I wish to use my app on dial up connections too
: : : :
: : : : I'm using Delphi 6.
: : :
: : : What exactly is it you are trying to do? Do you want the client to find the IP address of the server? That's not really practical. You have to tell a client where to connect to, it can't just pull IP addresses out of a hat.
: : :
: : : Is that what you're asking? If not, please explain with better detail.
: : :
: : Well, basically I'd like two PCs to communicate. The apps are simply passing strings back and forth.
: :
: : That's fairly easy across my home LAN where I can set IP addresses explicitly. In the client app, I can hardcode the IP address of the server, and while the server is in 'listening' mode, set the ClientSocket.Host of any client app to the pre-set IPaddr of the Server. Hey presto, connected.
: :
: : But to talk across the internet seems a more complex task. This is because the IPaddr of the server is no longer constant, as it's determined by my ISP. Consequently, my client apps cannot have the server IP address 'hard-coded' when use on the net.
: :
: : I don't really understand how to approach the problem, but have guessed that I can probably set up another app somewhere else, for example, on my website, which collects the current IP address of any of my apps dotted around the internet - that's the first place they check in to confirm their online presence. Client apps will consult this table of IP addresses to find out where the server(s) are. So my starting point was...How do I find out the IP address that has been allocated to me by my ISP today ? And start from there. Its difficult to define the problem more explicity as it is more an issue of 'how do I approach this' ? Maybe my appraoch is totally wrong. thanx for advice on way forward. Gazza
: :
:
:
: Okay, so you do want to do what I thought. It sounds like you need to sign up with a Dynamic DNS service. A good one I used to use is available at http://www.myip.us.
:

Ok thanks. As a final consideration, my app is likely to be distributed to individuals with a very small circle of contacts. A typical example is a disabled lady living in a residential home, who will use the app to 'chat' to a daughter in her house, living abroad, both of whom are using a local dial-up to the internet. The app sits on each PC and 'listens'. It can become a client or server app...if contacted, it becomes the server, and the contacting app becomes the client.

There are a large number of clients interested in this idea, so I can envisage quite a few of these one-to-one connections taking place at any time. Each pair will of course include one as server, one as client. And of course, each pair has nothing to do with any other 'pairs' currently in dialogue.

To clarify, does this mean I would need to get at least one of each pair to sign up with the site you recommend?
Report
Re: How to id IP address - LAN and Internet - using TClientSocket and Posted by Manning on 4 Dec 2003 at 6:38 AM
: : : : : Hi, I used to have IP addresses explicitly defined on my LAN, and my apps communicated ok using TClientSocket and TServerSocket (IP address was hard-coded).
: : : : :
: : : : : Now that I have changed this to obtain an IP address automatically, I need to find out my IP address at run time for my apps to communicate, over the LAN and over the internet.
: : : : :
: : : : : a) How can I discover my IP address, please ?
: : : : : b) Does it matter that I am using a broadband connection ? I wish to use my app on dial up connections too
: : : : :
: : : : : I'm using Delphi 6.
: : : :
: : : : What exactly is it you are trying to do? Do you want the client to find the IP address of the server? That's not really practical. You have to tell a client where to connect to, it can't just pull IP addresses out of a hat.
: : : :
: : : : Is that what you're asking? If not, please explain with better detail.
: : : :
: : : Well, basically I'd like two PCs to communicate. The apps are simply passing strings back and forth.
: : :
: : : That's fairly easy across my home LAN where I can set IP addresses explicitly. In the client app, I can hardcode the IP address of the server, and while the server is in 'listening' mode, set the ClientSocket.Host of any client app to the pre-set IPaddr of the Server. Hey presto, connected.
: : :
: : : But to talk across the internet seems a more complex task. This is because the IPaddr of the server is no longer constant, as it's determined by my ISP. Consequently, my client apps cannot have the server IP address 'hard-coded' when use on the net.
: : :
: : : I don't really understand how to approach the problem, but have guessed that I can probably set up another app somewhere else, for example, on my website, which collects the current IP address of any of my apps dotted around the internet - that's the first place they check in to confirm their online presence. Client apps will consult this table of IP addresses to find out where the server(s) are. So my starting point was...How do I find out the IP address that has been allocated to me by my ISP today ? And start from there. Its difficult to define the problem more explicity as it is more an issue of 'how do I approach this' ? Maybe my appraoch is totally wrong. thanx for advice on way forward. Gazza
: : :
: :
: :
: : Okay, so you do want to do what I thought. It sounds like you need to sign up with a Dynamic DNS service. A good one I used to use is available at http://www.myip.us.
: :
:
: Ok thanks. As a final consideration, my app is likely to be distributed to individuals with a very small circle of contacts. A typical example is a disabled lady living in a residential home, who will use the app to 'chat' to a daughter in her house, living abroad, both of whom are using a local dial-up to the internet. The app sits on each PC and 'listens'. It can become a client or server app...if contacted, it becomes the server, and the contacting app becomes the client.
:
: There are a large number of clients interested in this idea, so I can envisage quite a few of these one-to-one connections taking place at any time. Each pair will of course include one as server, one as client. And of course, each pair has nothing to do with any other 'pairs' currently in dialogue.
:
: To clarify, does this mean I would need to get at least one of each pair to sign up with the site you recommend?


Yes, anyone who wants to potentially act as the server would have to have an account with their own unique hostname. But with the extra details you provided, it sounds like your original idea of having another server that tracks the user names and ip addresses of any servers that the clients could then query to see if their server is online may work better.

Unfortunately I had a HD crash yesterday and I lost all my source code, otherwise I would have been able to provide you with the code to find out your local IP address. Since I can't now, I can only recommend going to www.torry.net and browsing the components their, or searching on Google for some code snippets.

I think also if you search on the C programming board I remember some code being posted not long ago. Since it's mainly WinAPI calls, it'll transfer to Delphi quite easily.
Report
Re: How to id IP address - LAN and Internet - using TClientSocket and Posted by GarryPaxton on 4 Dec 2003 at 10:59 AM
: : : : : : Hi, I used to have IP addresses explicitly defined on my LAN, and my apps communicated ok using TClientSocket and TServerSocket (IP address was hard-coded).
: : : : : :
: : : : : : Now that I have changed this to obtain an IP address automatically, I need to find out my IP address at run time for my apps to communicate, over the LAN and over the internet.
: : : : : :
: : : : : : a) How can I discover my IP address, please ?
: : : : : : b) Does it matter that I am using a broadband connection ? I wish to use my app on dial up connections too
: : : : : :
: : : : : : I'm using Delphi 6.
: : : : :
: : : : : What exactly is it you are trying to do? Do you want the client to find the IP address of the server? That's not really practical. You have to tell a client where to connect to, it can't just pull IP addresses out of a hat.
: : : : :
: : : : : Is that what you're asking? If not, please explain with better detail.
: : : : :
: : : : Well, basically I'd like two PCs to communicate. The apps are simply passing strings back and forth.
: : : :
: : : : That's fairly easy across my home LAN where I can set IP addresses explicitly. In the client app, I can hardcode the IP address of the server, and while the server is in 'listening' mode, set the ClientSocket.Host of any client app to the pre-set IPaddr of the Server. Hey presto, connected.
: : : :
: : : : But to talk across the internet seems a more complex task. This is because the IPaddr of the server is no longer constant, as it's determined by my ISP. Consequently, my client apps cannot have the server IP address 'hard-coded' when use on the net.
: : : :
: : : : I don't really understand how to approach the problem, but have guessed that I can probably set up another app somewhere else, for example, on my website, which collects the current IP address of any of my apps dotted around the internet - that's the first place they check in to confirm their online presence. Client apps will consult this table of IP addresses to find out where the server(s) are. So my starting point was...How do I find out the IP address that has been allocated to me by my ISP today ? And start from there. Its difficult to define the problem more explicity as it is more an issue of 'how do I approach this' ? Maybe my appraoch is totally wrong. thanx for advice on way forward. Gazza
: : : :
: : :
: : :
: : : Okay, so you do want to do what I thought. It sounds like you need to sign up with a Dynamic DNS service. A good one I used to use is available at http://www.myip.us.
: : :
: :
: : Ok thanks. As a final consideration, my app is likely to be distributed to individuals with a very small circle of contacts. A typical example is a disabled lady living in a residential home, who will use the app to 'chat' to a daughter in her house, living abroad, both of whom are using a local dial-up to the internet. The app sits on each PC and 'listens'. It can become a client or server app...if contacted, it becomes the server, and the contacting app becomes the client.
: :
: : There are a large number of clients interested in this idea, so I can envisage quite a few of these one-to-one connections taking place at any time. Each pair will of course include one as server, one as client. And of course, each pair has nothing to do with any other 'pairs' currently in dialogue.
: :
: : To clarify, does this mean I would need to get at least one of each pair to sign up with the site you recommend?
:
:
: Yes, anyone who wants to potentially act as the server would have to have an account with their own unique hostname. But with the extra details you provided, it sounds like your original idea of having another server that tracks the user names and ip addresses of any servers that the clients could then query to see if their server is online may work better.
:
: Unfortunately I had a HD crash yesterday and I lost all my source code, otherwise I would have been able to provide you with the code to find out your local IP address. Since I can't now, I can only recommend going to www.torry.net and browsing the components their, or searching on Google for some code snippets.
:
: I think also if you search on the C programming board I remember some code being posted not long ago. Since it's mainly WinAPI calls, it'll transfer to Delphi quite easily.
:
OK - I have enough to go off and do some research. many thanks for advice , Gazza
Report
Re: How to id IP address - LAN and Internet - using TClientSocket and Posted by venkat20 on 8 Sept 2009 at 11:33 PM
I found the Ip-address in the site http://www.ip-details.com/



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.