Well send() doesn't guarantee to send a whole block anyway (for a stream), so you need to deal with fragmentation on sending.
Likewise for reading from a file, you may as well read in fixed sized blocks, rather than to try to allocate some xMB buffer you're only going to use once.
Code:
char buff[BUFSIZ];
while ( (n=fread(buff,1,BUFSIZ,fp)) != 0 ) {
char *p = buff;
size_t remainder = n;
while ( remainder != 0 ) {
n = send(sock,p,remainder,0);
if ( n > 0 ) {
// advance by the amount actually sent
p += n;
remainder -= n;
} else if ( n == 0 ) {
// remote disconnected
} else {
// error
}
}
}
One more thing, it's a good idea to send the size of the file first, so the receiver knows how much data to expect.