digitalmars.D.learn - Get Local Ip Address?
- okibi (4/4) Jun 05 2007 Hey,
- Unknown W. Brackets (9/16) Jun 05 2007 Are you wanting the public IP address, or just the machine's IP address?
- okibi (3/24) Jun 05 2007 Assuming the computer is connected directly to the internet (via a cable...
- Unknown W. Brackets (7/35) Jun 05 2007 Most computers are not connected directly, since they usually have a
- okibi (3/42) Jun 06 2007 I know there's a way, and I can do it in C++, but I was just wondering i...
- Thomas Kuehne (24/26) Jun 06 2007 -----BEGIN PGP SIGNED MESSAGE-----
Hey, I was wondering if there is a simply way to get the public IP address of the machine. I need it to work on Windows and Linux. Is there a simply way that will work on both? Thanks!
Jun 05 2007
Are you wanting the public IP address, or just the machine's IP address? Example: my computer is in a network, so it's IP starts with 172.16. But, my public IP address starts with 72 or something (for my entire network.) To get the machine IP, it's going to be more system-specific, and I don't know off hand how. To get the public IP, you have to check an external source - e.g. http://www.whatismyip.org/. -[Unknown] okibi wrote:Hey, I was wondering if there is a simply way to get the public IP address of the machine. I need it to work on Windows and Linux. Is there a simply way that will work on both? Thanks!
Jun 05 2007
Assuming the computer is connected directly to the internet (via a cable modem or such), then it's IP should be the public IP. I guess, however, I'm asking how to get the machine's IP. Thanks. Unknown W. Brackets Wrote:Are you wanting the public IP address, or just the machine's IP address? Example: my computer is in a network, so it's IP starts with 172.16. But, my public IP address starts with 72 or something (for my entire network.) To get the machine IP, it's going to be more system-specific, and I don't know off hand how. To get the public IP, you have to check an external source - e.g. http://www.whatismyip.org/. -[Unknown] okibi wrote:Hey, I was wondering if there is a simply way to get the public IP address of the machine. I need it to work on Windows and Linux. Is there a simply way that will work on both? Thanks!
Jun 05 2007
Most computers are not connected directly, since they usually have a firewall (which most of the time involves a nat) in between. I've never had need to get a machine's IP (always let it be configurable or use ADDR_ANY) so I'm afraid I don't know how. I'm sure there's a way, but I suspect it varies by platform. -[Unknown] okibi wrote:Assuming the computer is connected directly to the internet (via a cable modem or such), then it's IP should be the public IP. I guess, however, I'm asking how to get the machine's IP. Thanks. Unknown W. Brackets Wrote:Are you wanting the public IP address, or just the machine's IP address? Example: my computer is in a network, so it's IP starts with 172.16. But, my public IP address starts with 72 or something (for my entire network.) To get the machine IP, it's going to be more system-specific, and I don't know off hand how. To get the public IP, you have to check an external source - e.g. http://www.whatismyip.org/. -[Unknown] okibi wrote:Hey, I was wondering if there is a simply way to get the public IP address of the machine. I need it to work on Windows and Linux. Is there a simply way that will work on both? Thanks!
Jun 05 2007
I know there's a way, and I can do it in C++, but I was just wondering if there is an easy multi-platform solution in D. Thanks guys! Unknown W. Brackets Wrote:Most computers are not connected directly, since they usually have a firewall (which most of the time involves a nat) in between. I've never had need to get a machine's IP (always let it be configurable or use ADDR_ANY) so I'm afraid I don't know how. I'm sure there's a way, but I suspect it varies by platform. -[Unknown] okibi wrote:Assuming the computer is connected directly to the internet (via a cable modem or such), then it's IP should be the public IP. I guess, however, I'm asking how to get the machine's IP. Thanks. Unknown W. Brackets Wrote:Are you wanting the public IP address, or just the machine's IP address? Example: my computer is in a network, so it's IP starts with 172.16. But, my public IP address starts with 72 or something (for my entire network.) To get the machine IP, it's going to be more system-specific, and I don't know off hand how. To get the public IP, you have to check an external source - e.g. http://www.whatismyip.org/. -[Unknown] okibi wrote:Hey, I was wondering if there is a simply way to get the public IP address of the machine. I need it to work on Windows and Linux. Is there a simply way that will work on both? Thanks!
Jun 06 2007
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 okibi schrieb am 2007-06-06:I know there's a way, and I can do it in C++, but I was just wondering if there is an easy multi-platform solution in D.There isn't. If you have an open socket you can get the local IP, however all network connected systems have at least 2 IPs: 127.0.0.1(IPv4) / ::1(IPv6) and a public one like 89.50.67.60. Many have more IPs (e.g. the system I'm posting from has 5 different ones), thus I'd like to know how you get the right local IP with C++. Thomas -----BEGIN PGP SIGNATURE----- iQIVAwUBRmbrubZlboUnBhRKAQJyTRAAhShvbIF8qa3e6u9lJWvNwo4EEAJ3XdAr pMELQgAIJDQETtn+8zHaUU/S22XwJ2s1d0BbfbJWXcqeLT9U9vgSGCPGD1Z8VcQK J+dGwYjB3NTXH5b/t/fTm2Bgbrnkm5gkFh2MMWNesKrCPKVMl5GRyd8RvYUA0K7c nOsPV7tpB5QQK+NwvFYVhPXCSATEBuCuhginYlyBlriar9OSY6qgoRXpxBXgss4E hAmrKhaWCUmhh+OtWW5m6n6DV8AYx8Xbep6dW+lO4zcSrMBxe2qbH0ljSil2XwNo dY9dBz/GFaorJltAmxJnmYmpO04ntYphVGpTBKZb3R5ghpNrObBvFTIofuDvvzl/ 9BpBiv8MVP9Fbc37TrP+osP0x0Ng/bktpCewbisNmxNJfio8BtArViFDTqncqqEy e4wLSgfFF1TAwt+NAlv9UFtmwLgAAV4ZML/HuTR2M8lYmmOaJxo7t1RvY+eLZzrd vpJH2Z85W8CLPfWIPpQgjhP1V94gm6A41ioCaHAQDgDXi9kbKc1fRykVjncnTJNN AxDYNY9notrn0NGVZGNdJ+XD+x5JETHeir0qc2/rMiyy4xSApcVCsA7Crex9R/9g CPvDs2/TZsVNI57rSvn/l/Ya4lFmIqUZX7o8AsypagAotC75osgXQ7QRybsrX0qG Po7z4cS1zzs= =bM+T -----END PGP SIGNATURE-----
Jun 06 2007