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



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

int opt = 1; 
int addrlen = sizeof(address); 
char buffer[1024] = {0}, schat[1024]; 
char *hello = "Hello from server"; 
char *bye = "bye"; 
 
printf("CREATING SERVER SOCKET .....\n"); 
// Creating socket file descriptor 
if ((server_fd = socket(AF_INET, SOCK_STREAM, 0)) == 0) 

perror("socket creation failed"); 
exit(EXIT_FAILURE); 


printf("DEFINING SERVER SOCKET OPTIONS, FAMILY, ADDRESS & 
PORT .....\n"); 
// Forcefully attaching socket to the port 8080 
if (setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR | SO_REUSEPORT, &opt, 
sizeof(opt))) 

perror("setsockopt failed"); 
exit(EXIT_FAILURE); 

address.sin_family = AF_INET; 
address.sin_addr.s_addr = INADDR_ANY; 
address.sin_port = htons( PORT ); 

printf("BINDING SERVER SOCKET TO PORT 8080 .....\n"); 
// Forcefully attaching socket to the port 8080 
if (bind(server_fd, (struct sockaddr *)&address, sizeof(address))<0) 


SOC3010 OPERATING SYSTEMS 
HOME ASSIGNMENT 3 
FALL 2022

perror("socket bind failed"); 
exit(EXIT_FAILURE); 


printf("SERVER LISTENING ON PORT 8080 FOR NEW CONNECTION.....\n"); 
if (listen(server_fd, 3) < 0) 

perror("sockeet listen failed "); 
exit(EXIT_FAILURE); 



if 
((new_socket 

accept(server_fd, 
(struct 
sockaddr 
*)&address, 
(socklen_t*)&addrlen))<0) 

Download 219,74 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8   9   ...   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