The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 04-20-2008
Saurabh78 Saurabh78 is offline
Registered User
 

Join Date: Jun 2004
Posts: 17
How to Get the hostent data

Hi,
I am trying to write a program, to find the open port on any system. Rightnow, my programm is working fine on the same system ip.

Now, i want to enhanced it to get any IP address and perform the task.
Problem is that, i have only IP address, like "111:111:111:111".
From this how to get the struct hostent *he;
I have tried with the following code

//he = gethostbyname( compName );
unsigned int addr = inet_addr("111:111:111:111");
hostent *he = gethostbyaddr((char *) &addr, 4, AF_INET);
But getgostbyaddress is returning NULL.
Any body help me.
Reply With Quote
Forum Sponsor