while(size!=0)
{
printf("loop start");
printf("File Size in int: %d \n",size);
byte_count = recv(sock,recv_data, 1024,0);
recv_data[byte_count] = '\0';
printf("hhahaha %d \n",10);
printf("char is:%c \n",recv_data[0]);
//fputc(recv_data[0], fpW);
size=size-1;
printf("loop end");
}
fclose(fpW);
This is a piece of Client side code .. i am sending data from Server Side but when i receive it on client side the recv call is blocked
the code how m i sending data from server is:
FILE *fp;
int ch;
if((fp = fopen("file.txt","rb"))==NULL) {
printf("Cannot open Source file.\n");
exit(1);
}
struct stat fileInfo;
stat("file.txt", &fileInfo);
int size=(int)fileInfo.st_size;
printf("File Size: %d \n",size);
fflush(stdout);
char msg1[10];
sprintf(msg1,"%i",size);
printf("File Size: %s \n",msg1);
send(client, msg1, sizeof(msg1),0);
//strcpy(msg1,NULL);
//msg1[0]='\0';
while((ch = (int)fgetc( fp )) != EOF) {
// sprintf(msg1,"%c",ch);
printf("%c",ch);
send(client,&ch, 1,0);
}
fclose(fp);
Please tell me why does it block on recv call
its urgent ... :(