Reputation: 13
Value of n
coming 9, sockfd = 3
and as it calls the read function, it was not coming out of the read function. After printing read start line, it stops there only:
while(1)
{
if (n < 0)
{
printf("ERROR writing to socket");
}
else if(n == 0)
{
printf("Nothing");
}
printf(" read start n=%d\n ,sockfd = %d\n",n,sockfd);
n = read(sockfd,buffer,1024);
if (n < 0)
{ error("ERROR reading from socket");
}
printf("Reply= %s",buffer);
write_buf_to_file("/root/abc_regr/receive.txt",buffer);
}
return;
Upvotes: 0
Views: 1791
Reputation: 9859
read()
is by default blocking call, so it will wait till it gets the data. If you want non-blocking function read answers of this question.
Upvotes: 1