1

Topic: The partial record from splice in UDP socket

Whether exists for a call//pipefd contains, at least, 42 bytes for reading//sockfd it is created with flag SOCK_DGRAM ssize_t n = splice (pipefd, 0, sockfd, 0, 42, 0) possibility to receive n distinct from-1, 0, 42? Differently, whether can splice write down only a part of queried data and generate the datagram? In that case the finite receiver receives the trimmed message, because under the standard if the datagram is read reads out it entirely. An additional question: as leads splice, if 1. In pipefd it is less than data, than 42. pipefd and sockfd the locked. 2. The same, only both descriptors not locked. As here often like to ask "what for" I will answer at once: I implement algorithm close to logic of a proxy of the server. The data arrives on pipefd, the title, residual through splice understands goes on sockfd where it is accepted already by a finite feast. Problem place that pipefd works in a streaming mode, and the data can come somehow, and sockfd2 - on UDP where it is necessary to provide integrity of the datagram. Therefore in the type code: struct header header; read (pipefd, &header, sizeof header);//Parse ` header `, do some logic. splice (pipefd, 0, sockfd, 0, header-> size, 0); the Call splice should move exactly header-> size byte.

2

Re: The partial record from splice in UDP socket

Hello, mbait, you wrote: M> M>//pipefd contains, at least, 42 bytes for reading M>//sockfd it is created with flag SOCK_DGRAM M> ssize_t n = splice (pipefd, 0, sockfd, 0, 42, 0) M> M> possibility to receive n distinct from-1, 0, 42? Differently, whether can splice write down only a part of queried data and generate the datagram? In that case the finite receiver receives the trimmed message, because under the standard if the datagram is read reads out it entirely. I suppose that  splice behaves, as read+write. I.e., in the resulted example 42 byte there is less it turns out, only if so much bytes are not present in , and ordered not locked . M> M> 1. In pipefd it is less than data, than 42. pipefd and sockfd the locked. M> 2. The same, only both descriptors not locked. M> in  it is not written, but I suppose that in 1st case will wait, and in the second sends, how many is. Thus if the socket UDP th, and in it "is not present a place" for record it does not lead to that will be sent a half-packet, and can lead only to that the whole packet, but will be sent later. M> As here often like to ask "what for" I will answer at once: I implement algorithm close to logic of a proxy of the server. The data arrives on pipefd, the title, residual through splice understands goes on sockfd where it is accepted already by a finite feast. A problem place that pipefd works in a streaming mode, and the data can come somehow, and sockfd2 - on UDP where it is necessary to provide integrity of the datagram. Therefore in the type code: I very much doubt that in this case fuss with  gives though any scoring in respect of optimization. Looks, as typical premature optimization, which root of all evil.  should give a noticeable scoring when we pour given by a stream from one place into another, and we send , multiple to page, instead of we bite off  that gives the chance to a kernel not to copy bytes, and to shift the whole pages from place to place.