-
Notifications
You must be signed in to change notification settings - Fork 1
/
slide_client.c
42 lines (40 loc) · 902 Bytes
/
slide_client.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<sys/socket.h>
#include<sys/types.h>
#include<netinet/in.h>
int main()
{
int sfd,lfd,len,choice;
char str[20],str1[20],err[20];
struct sockaddr_in saddr,caddr;
sfd=socket(AF_INET,SOCK_STREAM,0);
if(sfd<0)
perror("socket creation Error");
bzero(&saddr,sizeof(saddr));
saddr.sin_family=AF_INET;
saddr.sin_addr.s_addr=INADDR_ANY;
saddr.sin_port=htons(5000);
connect(sfd,(struct sockaddr*)&saddr,sizeof(saddr));
for(;;)
{
read(sfd,str,20);
if(!strcmp(str,"exit"))
{
printf("Exiting\n");
break;
}
printf("\n\nReceived : %s \n1.Do u want to report an error(1-Yes 0-No) : ",str);
scanf("%d",&choice);
if(!choice)
write(sfd,"-1",sizeof("-1"));
else
{
printf("Enter the sequence no of the frame where error has occured : ");
scanf("%s",err);
write(sfd,err,sizeof(err));
}
printf("\n");
}
}