![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Copying multiple folders to local machine (don't know folder names) | leenyburger | UNIX for Dummies Questions & Answers | 5 | 06-12-2008 07:38 AM |
| Workgroup of local machine | skumar2011 | IP Networking | 3 | 10-10-2007 10:03 AM |
| how to retrieve IP address of a machine | mridula | IP Networking | 5 | 11-02-2005 09:21 AM |
| [FTP]opying of file from remote to local machine | sonbag_pspl | SUN Solaris | 1 | 08-12-2004 04:15 AM |
| copy files from local drive to telnet unix machine. | gary | UNIX for Dummies Questions & Answers | 4 | 05-24-2001 04:24 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
try this,
Code:
# include<netdb.h>
# include<stdio.h>
# include<netinet/in.h>
# include<arpa/inet.h>
# include<sys/socket.h>
int main(int argc, char *argv[])
{
long conv;
struct hostent *h;
if(argc != 2)
{
fprintf(stderr, "USAGE: <binary> <IP_ADDRESS>\n");
exit(1);
}
if( (int) (conv=inet_addr(argv[1])) == -1 )
{
fprintf(stderr, "IP Notation Wrong\n");
exit(1);
}
h=gethostbyaddr((char*)&conv, sizeof(conv), AF_INET);
if(h == (struct hostent *) NULL)
{
fprintf(stderr, "Resolve failed for %s\n", argv[1]);
exit(1);
}
fprintf(stderr, "Name: %s\n", h->h_name);
return 0;
}
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|