I trying to write a small code to send a file over network on Windows, but it seem not work properly. This is my code:
char *arrFile = readFile("test.exe");
int fileSize = getFileSize("test.exe");
int sentSize = 0;
int justSent;
while(sentSize < fileSize) {
justSent = send(sock, arrFile + sentSize, fileSize - sentSize, 0);
sentSize += justSent;
}
It got error at send function after several loops, I don't know why, Can someone tell me the reason (and solution of couse :D)?
Update
I'm using non-blocking socket and get 'WSAEWOULDBLOCK' error but it still don't send anything after error until client send back something :-(
Above code is C, but C++ as well :D