Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
i have some idea about file remote location.Can i split a file in to chunks and use thread control split and socket to implement split data and send meanwhile ?
Besides, local can prefetch remote chunk and read it by two thread?
If you have one source of data and one sink I would assume that chunking won't help.
The IP-stack itself uses this method, so as long as you can provide data fast enough to the TCP stack (write buffer) and are fast enough reading the data from the buffer (read buffer) I think that is as fast as it gets...
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 months ago.
Improve this question
In C (or C++) is there a way to receive data from a socket, but instead of reading it into a buffer in memory, it "receives" it into a file. I know that the usual way to do this is to receive the data into a char buffer, then write the buffer into a file.
Is there a function like sendfile(), which transports the data directly between files and sockets, but instead of sending data from a file to a socket, it receives data from the socket into a file?
There is no equivalent to sendfile that works the other way around. But there is splice() that transfers between 2 file descriptors, one of them must refer to a file.
So what you can do is socket -> pipe, pipe -> file. Whether that is still a gain over a buffer you have to measure. Splice is limited by the pipe buffer size while a read/write can work in arbitrary units reducing the number of syscalls.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I want to transfer 32k data between client-server with WinSock2. Is it possible or there is a limitation with data?
"I want to transfer 32k data between client-server with WinSock2. Is it possible" - Yes.
32K is tiny. If you had asked about 2^32 or 2^64 bits of data, then you may have a situation where you could run into trouble. But 32K? No.
Also; Why didn't you just try? A simple test program would have shown you i 5min that transfering 32K of data is not a problem at all. Please make a minimal effort before asking a question.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Just wondering, what would be the most efficient way to write same data to two files, on linux and C/C++.
For example, this is the most trivial way.
while(1) {
... getting data from somewhere ....
write(fd1, data, datalen);
write(fd2, data, datalen);
}
However, the disadvantage is that kernel needs to copy data twice even though the data is same.
Any thoughts?
what would be the most efficient way to write same data to two files
Write the data to one file only.
Copy that file to another. Use an OS call to do that efficiently (Copy a file in a sane, safe and efficient way).
Another way for step 2 would be to create a hard link (check link()).
However, please watch out of not becomning a victim of premature optimization. I this is not the bottleneck in your program, then just use the trivial, easy-it-read approach.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have a std::multimap variable containing key-value data, and want to transfer it to a remote server over socket.
I known, in Java, we can serialize the object as byte stream and transfer it.
However, can I do the same thing in C++?
If not, how can I transfer std::multimap data over socket in C++?
Meanwhile, are there some other methods to transfer std::multimap data over socket without serialization, or using 3rd library?
Thanks in advance!
It can be done through boost::serialization, STL collection of it can be found here
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have a USRP N200 with WBX daughterboard. I'd need a simple C/C++
program that can simultaneously receive and transmit. but I can't find It.
Look at the examples that come with UHD. There's the txrx loopback example which does exactly that.
In essence, it's not complicated:
spawn a thread for receiving and one for transmitting. This is optional, but it will make your system much less prone to receive sample over- or transmit sample underruns.
create an rx_streamer and a tx_streamer
In the RX thread, call the rx_streamer->recv() method repeatedly in the TX thread, tx_streamer->send() method repeatedly.