View Single Post
Old Jul 3rd, 2005, 9:15 AM   #3
mackenga
Professional Programmer
 
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 317
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