Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 12th, 2005, 5:07 PM   #1
sonson
Newbie
 
Join Date: Jun 2005
Posts: 8
Rep Power: 0 sonson is on a distinguished road
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?
sonson is offline   Reply With Quote
Old Jun 23rd, 2005, 7:23 PM   #2
Cerulean
Professional Programmer
 
Cerulean's Avatar
 
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4 Cerulean is on a distinguished road
You don't need a domain name to connect to a box on a port. If you have the IP, you can connect already.
Cerulean is offline   Reply With Quote
Old Jul 3rd, 2005, 9:15 AM   #3
mackenga
Professional Programmer
 
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 314
Rep Power: 4 mackenga is on a distinguished road
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.
mackenga is offline   Reply With Quote
Old Jul 10th, 2005, 10:11 AM   #4
Cerulean
Professional Programmer
 
Cerulean's Avatar
 
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4 Cerulean is on a distinguished road
Quote:
Well, the dotted-decimal IP isn't enough to connect to;
Am I missing something? All you need is the IP and port number. He already has the port number.
Cerulean is offline   Reply With Quote
Old Jul 12th, 2005, 5:45 PM   #5
mackenga
Professional Programmer
 
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 314
Rep Power: 4 mackenga is on a distinguished road
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!
mackenga is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:51 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC