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



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

char *bye = "bye"; 
 
printf("CREATING CLIENT SOCKET .....\n"); 
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) 

printf("\n Socket creation error \n"); 
return -1; 


printf("DEFINING CLIENT SOCKET FAMILY, ADDRESS & PORT .....\n"); 
memset(&serv_addr, '0', sizeof(serv_addr)); 
serv_addr.sin_family = AF_INET; 
serv_addr.sin_port = htons(PORT); 
// Convert IPv4 and IPv6 addresses from text to binary form 
if(inet_pton(AF_INET, "127.0.0.1", &serv_addr.sin_addr)<=0)

printf("\nInvalid address/ Address not supported \n"); 
return -1; 


printf("CLIENT CONNECTING ON PORT 8080 TO COMMUNICATE WITH 
SERVER.....\n"); 
if (connect(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) 

printf("\nConnection Failed \n"); 
return -1; 

 
send(sock , hello , strlen(hello) , 0 ); 
printf("Hello message sent\n"); 
valread = read( sock , buffer, 1024); 
printf("%s\n",buffer ); 
printf(" Ready for Chat....\n"); 
while(1) 

memset(buffer, 0, sizeof(buffer)); 
memset(cchat, 0, sizeof(cchat)); 


SOC3010 OPERATING SYSTEMS 
HOME ASSIGNMENT 3 
FALL 2022
printf("CLIENT : "); 
fgets (cchat, sizeof(cchat), stdin); 
send(sock , cchat , strlen(cchat) , 0 ); 
valread = read( sock , buffer, 1024); 
printf("%s\n",buffer ); 
cchat[strlen(cchat)] = '\0'; 
if(strncmp(cchat, bye, strlen(bye))==0) 
break; 

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