Hi alls,
I have a problem with sending a file over TCP socket. I want to use sendfile() because it seems to be the quickest (easiest) way. Currently my "server" can send files smaller than N bytes because my send_buffer is N bytes big. It works fine with verry small files, but I want to send files of few Mega Bytes not few Bytes, and even larger, without having to thing about it's size.
server works like this: fread() -> send_buffer -> send()
client (not yet implemented, I use netcat instead): nc ip_addr port > test1
When I put these in while() I receive file but it has a tail filled with "@" signs (when i read it with vi editor). This is why I need to use sendfile() - it's much simpler, but I don't know how :r
PLEASE HELP
THANKS IN ADVANCE :e
I have a problem with sending a file over TCP socket. I want to use sendfile() because it seems to be the quickest (easiest) way. Currently my "server" can send files smaller than N bytes because my send_buffer is N bytes big. It works fine with verry small files, but I want to send files of few Mega Bytes not few Bytes, and even larger, without having to thing about it's size.
server works like this: fread() -> send_buffer -> send()
client (not yet implemented, I use netcat instead): nc ip_addr port > test1
Code:
while(!feof(file)) {
char filebuffer[N];
fread (filebuffer, sizeof(char), N, file);
send (sockfd, filebuffer, (sizeof (char) * N), 0);
}
When I put these in while() I receive file but it has a tail filled with "@" signs (when i read it with vi editor). This is why I need to use sendfile() - it's much simpler, but I don't know how :r
PLEASE HELP
THANKS IN ADVANCE :e