![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: Jun 2005
Posts: 8
Rep Power: 0
![]() |
ip address lookup
iam currently just writing a little script which loooks up ip addresses in a specfic location...
so what i will have is something like this.. Enter ip adresss *************...then it goes to a the location looks up the address and connects to the specifc port to connect to the server.. any ideas? ![]() |
|
|
|
|
|
#2 |
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
You don't need a domain name to connect to a box on a port. If you have the IP, you can connect already.
|
|
|
|
|
|
#3 |
|
Professional Programmer
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 317
Rep Power: 4
![]() |
Well, the dotted-decimal IP isn't enough to connect to; it's been a year or two since I did any socket programming with Perl, but I seem to recall you need to use inet_pton() (or is it inet_aton()? Presentation or alpha? I think it's inet_aton() actually), kinda like:
socket(SOCK, AF_INET, getprotobyname('tcp'));
connect(SOCK, sockaddr_in($port, inet_aton($ipOrHostname)));I may be mixing my C and Perl by this point but I hope that's helpful. If in doubt, perlfunc is always a handy man page. Interestingly, I seem to recall Perl's inet_aton() doesn't mind if you give it a hostname; it'll do the lookup transparently for you. |
|
|
|
|
|
#4 | |
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
Quote:
|
|
|
|
|
|
|
#5 |
|
Professional Programmer
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 317
Rep Power: 4
![]() |
It's enough information, yes; what I was getting at was that it would need a little translation from inet_aton() before it could go anywhere near connect(). Sorry for any confusion!
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|