sendfile is the general function representation of sending data/file over the network. The network may be raw tcp sockets or any other connection itself. This tag should be used for querying about such file sending methods defined in different web/(android etc.) frameworks
Questions tagged [sendfile]
279 questions
3
votes
1 answer
Invalid argument in sendfile() with two regular files
I'm trying to test the sendfile() system call under Linux 2.6.32 to zero-copy data between two regular files.
As far as I understand, it should work: ever since 2.6.22, sendfile() has been implemented using splice(), and both the input file and the…

Daniel Hershcovich
- 3,751
- 2
- 30
- 35
3
votes
3 answers
Terminology: opposite of "zero copy"?
We're benchmarking some code that we've converted to use sendfile(), the linux zero-copy system call. What's the term for the traditional read()/write() loop that sendfile() replaces? I.e., in our report I want to say "zerocopy is X millisecs, and…

Mark Harrison
- 297,451
- 125
- 333
- 465
3
votes
1 answer
Differnce between linux write and sendfile syscall
Im programming webserver (C), which should send big files. My question is:
What are the main differences in two syscalls: write and sendfile. Does sendfile depends on size of socket system buffer? I noticed that write often writes less then I…

JosiP
- 225
- 1
- 4
- 11
3
votes
1 answer
Ruby on Rails - send_file is not working
I wrote the following code.
def help_doc
pdf_filename = File.join(Rails.root, "/public/doc.pdf")
send_file(pdf_filename, :filename => "doc.pdf" :type => "application/pdf", :diposition => "inline")
end
It's working, but not as I want. I'd like…

user3111900
- 31
- 2
3
votes
2 answers
Is writing to a socket an arbitrary limitation of the sendfile() syscall?
Prelude
sendfile() is an extremely useful syscall for two reasons:
First, it's less code than a read()/write() (or recv()/send() if you prefer that jive) loop.
Second, it's faster (less syscalls, implementation may copy between devices without…

Sufian
- 8,627
- 4
- 22
- 24
3
votes
1 answer
Linux >2.6.33: could sendfile() be used to implement a faster 'cat'?
Having to concatenate lots of large files into an even larger single one, we currently use cat file1 file2 ... output_file
but are wondering whether it could be done faster than with that old friend.
Reading the man page of sendfile(), one can…

Christian
- 151
- 3
3
votes
2 answers
create a download link with rails to an external file with at URL
I moved my file storage to Rackspace Cloudfiles and it broke my send_file action.
old
def full_res_download
@asset = Asset.find(params[:id])
@file = "#{Rails.root}/public#{@asset.full_res}"
send_file @file
end
new
def full_res_download
…

T. Weston Kendall
- 349
- 6
- 17
2
votes
0 answers
Linux sendfile() then overwrite the file, sendfile() send overwritten data
I am developing a program by read data from disk and sent to network socket.
I use memfd_create() to create a memory file as buffer and get the mem_fd, use ftruncate() to set the file size, and mmap() to map the buffer address buf.
The program…

ivan_wl
- 51
- 5
2
votes
1 answer
How to send zip file with send_file flask framework
I am having an issue trying to download download in-memory ZIP-FILE object using Flask send_file. my zip exists in memory and is full of text documents but when I try with this code
the result I get is: it downloads like it is supposed to but it…

Josh.h
- 71
- 1
- 13
2
votes
3 answers
Flask: delete file from server after send_file() is completed
I have a Flask backend which generates an image based on some user input, and sends this image to the client side using the send_file() function of Flask.
This is the Python server code:
@app.route('/image',methods=['POST'])
def generate_image():
…

RishiC
- 768
- 1
- 10
- 34
2
votes
2 answers
Always use sendfile with nginx on Linux?
The nginx HTTP server has a directive named sendfile, which can tell it to use the Linux sendfile() system call to do I/O without copying to an intermediate memory buffer. That should increase the I/O rate and reduce memory use. If you are running…

Raedwald
- 46,613
- 43
- 151
- 237
2
votes
3 answers
Fetch image in React from Node.js request
When needed, React asks for an image using Superagent :
exports.getImgFromSection=function(id,request){
request
.get('/img/'+id)
.end((error, response) => {
if (!error && response) {
…

Pol Grisart
- 179
- 4
- 13
2
votes
2 answers
Not sending file correctly. Sockets. C
I am writing a program that a client can ask for files to a server. Then the server will send them in chunks of 512 bytes. The problem is that when the client read the file:
*Sometimes the first 512 bytes are different from the original file. The…

boludo kid
- 154
- 1
- 12
2
votes
1 answer
Send a large file with HTTP.jl
I would like to implement a server with HTTP.jl and julia. After some computation the server would return a "large" file (about several 100 MB). I would like to avoid having to read all the file in memory and then send it to the client.
Some…

Alex338207
- 1,825
- 12
- 16
2
votes
2 answers
Stuck in while when transfer file through socket using TCP
I write program and it works fine, but i want to rewrite it using sendfile() and now i got stuck in a loop.
Server side:
send name = ok
send md5 checksum = ok
send size = ok
send file = ko
Client side:
recv name = ok
recv md5 cecksum =…

Nick S
- 1,299
- 1
- 11
- 23