Skip to content
This repository was archived by the owner on Jun 9, 2021. It is now read-only.

Commit e394df5

Browse files
committed
Updated
1 parent 858b55a commit e394df5

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

list_content.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ void list_content(char *arg, char *user_input, int sockfd)
1010
int newsockfd;
1111

1212
struct timeval tm;/* time structure to set time wait for receive buffer */
13-
tm.tv_sec = 1;
13+
tm.tv_sec = 4;
1414
tm.tv_usec = 750000;
1515

1616
char message_from_server[MAXSZ];
@@ -99,12 +99,7 @@ void list_content(char *arg, char *user_input, int sockfd)
9999
close(newsockfd);/* Close PASSIVE connection */
100100

101101
/* Set time boundation on receive buffer */
102-
if(setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO,(char *)&tm,sizeof(tm)) == -1)
103-
{
104-
perror("Error");
105-
exit(1);
106-
}
107-
102+
setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO,(char *)&tm,sizeof(tm));
108103
while((no_of_bytes = recv(sockfd,message_from_server,MAXSZ,0)) > 0)
109104
{
110105
message_from_server[no_of_bytes] = '\0';
@@ -114,6 +109,10 @@ void list_content(char *arg, char *user_input, int sockfd)
114109
break;
115110
}
116111
printf("\n");
112+
113+
tm.tv_sec = 0;
114+
tm.tv_usec = 0;
115+
setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO,(char *)&tm,sizeof(tm));
117116
}
118117

119118
}

0 commit comments

Comments
 (0)