You are not logged in.
Pages: 1
Here are the partial of the sub function codes for the sending and receiving file over tcp which is located in the same file:
called from client code using sendingFile(filename, filebytes)
void sendingFile(char* sendFile, int sendSize) {
.
.
.
/* open file for reading */
...
while ((n = read(fdin, data, 100)) > 0){
.
.
.
if((n2 = write(sockfd, ptr, n)) < 0) {
perror("Socket writing error");
exit(1);
}
.
.
}
}
/* close file */
return;
}
called from server code using receivingFile(sockfd, filename, filebytes)
void receivingFile(int getsockfd, char* getFile, int getSize) {
.
.
.
/* open new file for reading */
/* compare new file size with reading file size */
n = read(getsockfd, data, min(100, getSize-curr));
/* write to file */char *ptr = data;
.
.
.
.
/* getting new file current write size */
}
}
/* close writing file */
return;
}
If i put the sendingFile code directly into the client code without using subfunction. It works. But it doesn't work once using it as subfunction. Am i suppose to return anything from the sendingFile or?
Offline
Pages: 1