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



Download 219,74 Kb.
Pdf ko'rish
bet14/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

 
 


SOC3010 OPERATING SYSTEMS 
HOME ASSIGNMENT 3 
FALL 2022
11.
Consider the following Program Handling multiple clients on server 
with multi threading
 Filename : servermt.c 
//Handle multiple socket connections with threads 
//To handle every connection we need a separate handling code to run along
//with the main server accepting connections. 
//One way to achieve this is using threads.
//The main server program accepts a connection and creates a new thread to 
//handle
//communication for the connection, and then the server goes back to
//accept more connections. 
//On Linux threading can be done with the pthread (posix threads) library.
// use threads to create handlers for each connection the server accepts 
 
 
#include 
#include //strlen 
#include //strlen 
#include 
#include //inet_addr 
#include //write 
#include
//for threading , link with lpthread 

void *connection_handler(void *); 

int main(int argc , char *argv[]) 

int socket_desc , new_socket , c , *new_sock; 
struct sockaddr_in server , client; 
char *message; 
//Create socket 
socket_desc = socket(AF_INET , SOCK_STREAM , 0); 
if (socket_desc == -1) 

printf("Could not create socket"); 


//Prepare the sockaddr_in structure 
server.sin_family = AF_INET; 
server.sin_addr.s_addr = INADDR_ANY; 
server.sin_port = htons( 9999 ); 


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