I am creating client-server application.
client sends text file through sendto()
function to server.
Problems are following--
1>At the server i am writing into new abc.txt file.
but problem is it writes some garbage data also....
server side function ----
char RecvBuf[22610];
int BufLen = 22610;
recvfrom(RecvSocket,RecvBuf,BufLen, 0,(SOCKADDR *)&SenderAddr, &SenderAddrSize);
FILE * pFile;
pFile = fopen ("abc.txt" , "w");
fwrite (RecvBuf , 1 ,sizeof(RecvBuf) , pFile);
fclose (pFile);
2> When i am execute exe by using system command it creates info.txt
some time this file size is 27kb otherwise 23/30/15/5 kb
is problem occurs because of i m not sending correct file size through socket???
client side function----
char SendBuf[22610];
int BufLen = 22630;
char buffer[25000];
pFile = fopen ("info.txt" , "r");
while(!feof(pFile))
{
fread (SendBuf , 1 ,sizeof(SendBuf) , pFile);
sendto(SendSocket, SendBuf,BufLen,0,(SOCKADDR *) &RecvAddr,sizeof(RecvAddr));
}
fclose (pFile);
How to solve this problem???