Note that there are some explanatory texts on larger screens.

plurals
  1. POreceive from unix local socket and buffer size
    primarykey
    data
    text
    <p>I'm having a problem with unix local sockets. While reading a message that's longer than my temp buffer size, the request takes too long (maybe indefinitely).</p> <p><strong>Added after some tests:</strong> there is still problem with freeze at ::recv. when I send (1023*8) bytes or less to the UNIX socket - all ok, but when sended more than (1023*9) - i get freeze on recv command. <strong>maybe its FreeBSD default UNIX socket limit or C++ default socket settings? Who know?</strong></p> <hr> <h2>i made some additational tests and I am 100% sure that its "freeze" on the last 9th itteration when executing ::recv command, when trying to read message >= (1023*9) bytes long. (first 8th itterationg going well.)</h2> <p><strong>What I'm doing:</strong> The idea is to read in a do/while loop from a socket with </p> <pre><code>::recv (current_socket, buf, 1024, 0); </code></pre> <p>and check <code>buf</code> for a SPECIAL SYMBOL. If not found:</p> <ol> <li>merge content of buffer to <code>stringxxx += buf;</code></li> <li>bzero temp buf </li> <li>continue the ::recv loop</li> </ol> <p><strong>How do I fix the issue with the request taking too long in the while loop?</strong></p> <p>Is there a better way to clear the buffer? Currently, it's: </p> <pre><code> char buf [1025]; bzero(buf, 1025); </code></pre> <p>But I know bzero is deprecated in the new c++ standard.</p> <p><strong>EDIT:</strong> *<em>"Why need to clean the buffer</em>*</p> <p>I see questions at comments with this question. Without buffer cleanup on the next(last) itteration of reading to the buffer, it will contain the "tail" of first part of the message.</p> <p>Example:</p> <pre><code> // message at the socket is "AAAAAACDE" char buf [6]; ::recv (current_socket, buf, 6, 0); // read 6 symbols, buf = "AAAAAA" // no cleanup, read the last part of the message with recv ::recv (current_socket, buf, 6, 0); // read 6 symbols, but buffer contain only 3 not readed before symbols, therefore // buf now contain "CDEAAA" (not correct, we waiting for CDE only) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload