bridging between two file descriptors

前端 未结 2 1615
轻奢々
轻奢々 2021-02-14 10:25

I have a socket I\'m doing select() on it, waiting for other process to write. Once it write, I read the data, and write it to another file descriptor. My question

2条回答
  •  情书的邮戳
    2021-02-14 11:28

    Sorry if I misunderstood your situation, but do you mean something like sendfile?

    sendfile - transfer data between file descriptors

    #include 
    ssize_t sendfile(int out_fd, int in_fd, off_t * offset ", size_t" " count" );
    

    sendfile() copies data between one file descriptor and another. Because this copying is done within the kernel, sendfile() is more efficient than the combination of read(2) and write(2), which would require transferring data to and from user space.

提交回复
热议问题