Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <netdb.h>
- #include <netinet/in.h>
- #include <arpa/inet.h>
- #include <iostream>
- using namespace std;
- int main() {
- const char name[] = "seberm.com";
- /*
- * char *h_name Official name of the host.
- char **h_aliases A pointer to an array of pointers to
- alternative host names, terminated by a
- null pointer.
- int h_addrtype Address type.
- int h_length The length, in bytes, of the address.
- char **h_addr_list A pointer to an array of pointers to network
- addresses (in network byte order) for the host,
- terminated by a null pointer.
- */
- hostent *h = gethostbyname(name);
- cout << "\nname: " << h->h_name << "\n";
- int key = 0;
- while (h->h_addr_list[key] != NULL) {
- // adresu jsme ziskali v binarni podobne a musime ji prevest fci inet_ntoa na klasickou podobu
- cout << "\nAdresa: " << inet_ntoa(*(in_addr*)h->h_addr_list[key]);
- key++;
- }
- cout << "\n\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement