Instructions : all home assignments are to be completed in groups of


/* It takes the domain name as the parameter and returns a structure of type hostent



Download 219,74 Kb.
Pdf ko'rish
bet8/17
Sana12.11.2022
Hajmi219,74 Kb.
#864723
1   ...   4   5   6   7   8   9   10   11   ...   17
Bog'liq
SOC3010 OS HOME ASSIGNMENT 3 FALL 2022

/* It takes the domain name as the parameter and returns a structure of type hostent.
*/
/* This structure has the ip information.
*/
/* It is present in netdb.h. Lets have a look at this structure
*/
/* Description of data base entry for a single host.
*/ 
 
/* struct hostent
*/
/* {
*/
/* char *h_name; Official name of host.
*/
/* char **h_aliases; Alias list.
*/
/* int h_addrtype; Host address type.
*/
/* int h_length; Length of address.
*/
/* char **h_addr_list; List of addresses from name server.
*/
/* };
*/
/* The h_addr_list has the IP addresses.
*/
#include //printf
#include //strcpy
#include
#include //hostent
#include
 
int main(int argc , char *argv[])
{
char *hostname;
char ip[100];
struct hostent *he;
struct in_addr **addr_list;
int i; 
if(argc == 2 )
{
hostname = argv[1];
if ( (he = gethostbyname( hostname ) ) == NULL) 
{
//gethostbyname failed
herror("gethostbyname");
return 1;
}
 //Cast the h_addr_list to in_addr , since h_addr_list also has the ip address in long format 
only


SOC3010 OPERATING SYSTEMS 
HOME ASSIGNMENT 3 
FALL 2022
addr_list = (struct in_addr **) he->h_addr_list;

for(i = 0; addr_list[i] != NULL; i++) 

Download 219,74 Kb.

Do'stlaringiz bilan baham:
1   ...   4   5   6   7   8   9   10   11   ...   17




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish