How to finding a Machine Address?
Submitted by: AdministratorFinding an address that can be used to connect to a remote machine is done with either of the following commands:
#include <netdb.h>
struct hostent *gethostbyname(char *name)
struct hostent *gethostbyaddr(char *addr,
int len, int type)
name contains the host name for which the IP address is needed. addr points to a structure of type in_addr and len is the size in bytes of this structure. In this discussion type is always AF_INET since the discussion is limited to use of IP addresses on the Internet.
Both calls return a pointer to a host entry structure.
This structure has the following form:
struct hostent {
char *h_name; /*official name of host*/
char **h_aliases; /* alias list */
int h_addrtype; /* address type */
int h_length; /* length of address */
char **h_addr_list;
/* list of addresses from name server */
#define h_addr h_addr_list[0]
/* address for backward compatibility */
};
Submitted by: Administrator
#include <netdb.h>
struct hostent *gethostbyname(char *name)
struct hostent *gethostbyaddr(char *addr,
int len, int type)
name contains the host name for which the IP address is needed. addr points to a structure of type in_addr and len is the size in bytes of this structure. In this discussion type is always AF_INET since the discussion is limited to use of IP addresses on the Internet.
Both calls return a pointer to a host entry structure.
This structure has the following form:
struct hostent {
char *h_name; /*official name of host*/
char **h_aliases; /* alias list */
int h_addrtype; /* address type */
int h_length; /* length of address */
char **h_addr_list;
/* list of addresses from name server */
#define h_addr h_addr_list[0]
/* address for backward compatibility */
};
Submitted by: Administrator
Read Online Socket Programming Job Interview Questions And Answers
Top Socket Programming Questions
☺ | Socket Programming Interview Questions |
☺ | How does the race condition occur? |
☺ | What Is Socket? |
☺ | Socket Programming in C using TCP with Code? |
☺ | What is the difference between TCP and UDP? |
Top Coding/Programming Categories
☺ | Python Interview Questions. |
☺ | OOP Interview Questions. |
☺ | Software engineering Interview Questions. |
☺ | PHP Interview Questions. |
☺ | VBA (Visual Basic for Applications) Interview Questions. |