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


printf("Adding to list of sockets as %d\n" , i)



Download 219,74 Kb.
Pdf ko'rish
bet13/17
Sana12.11.2022
Hajmi219,74 Kb.
#864723
1   ...   9   10   11   12   13   14   15   16   17
Bog'liq
SOC3010 OS HOME ASSIGNMENT 3 FALL 2022

printf("Adding to list of sockets as %d\n" , i);

break;
}
}
}
//else its some IO operation on some other socket 


SOC3010 OPERATING SYSTEMS 
HOME ASSIGNMENT 3 
FALL 2022
for (i = 0; i < max_clients; i++)
{
sd = client_socket[i];

if (FD_ISSET( sd , &readfds))
{
//Check if it was for closing , and also read the
//incoming message
if ((valread = read( sd , buffer, 1024)) == 0)
{
//Somebody disconnected , get his details and print
getpeername(sd , (struct sockaddr*)&address , (socklen_t*)&addrlen);
printf("Host disconnected , ip %s , port %d \n" , inet_ntoa(address.sin_addr) , 
ntohs(address.sin_port));

//Close the socket and mark as 0 in list for reuse
close( sd );
client_socket[i] = 0;
}

//Echo back the message that came in
else 
{
//set the string terminating NULL byte on the end
//of the data read
buffer[valread] = '\0';
send(sd , buffer , strlen(buffer) , 0 );
}
}
}
}

return 0;
}
 
Compile the file and run the server. 
$gcc –o servernmt servernmt.c 
Now setup the server on the machine by entering the command : 
$./servernmt 
 
Use telnet to connect to the server as a client from other xterms. 
Try running on different machines/xterms using following command: 
telnet localhost 8888 

 

Download 219,74 Kb.

Do'stlaringiz bilan baham:
1   ...   9   10   11   12   13   14   15   16   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