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 4 months ago.
Improve this question
I am using a client socket to make a HTTP call to retrieve an image. Even though the recv call receives 36791 bytes, the buffer only has 4 bytes in the response body (the BUFF_SIZE has been set to 50000 for testing purposes). I have tried to make subsequent calls to recv but 0 bytes are returned from the subsequent calls. Would appreciate any help to understand why the buffer does not contain the full response from the socket recv as expected.
Issue was due to null-terminated strings as pointed out by #dewaffled, used std::string(buffer, total) as a solution to create a string that allows embedded null characters inspired by this post
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 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.
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
What happens if a processors sends exactly the same message to the same destination with the same tag? When the receiver wants to read it, does it read the last one?
What if two different processors send the same message (same tag) to one processor? which one it receive and in what order?
3- How we can know how many pending messages from a specific processor are in the queue in order to receive all of them?
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...