• 请不要在回答技术问题时复制粘贴 AI 生成的内容
Sherlockhlt
V2EX  ›  程序员

sendfile接收文件如何知道文件大小?

  •  
  •   Sherlockhlt · Nov 26, 2013 · 3743 views
    This topic created in 4732 days ago, the information mentioned may be changed or developed.
    Man了下,
    sendfile发送文件是把sockfd写在前,fd写在后
    接收文件是反过来
    可是接收时候,那个文件大小如何知道呢?
    发送文件是stat(fd)获得文件大小
    接收的时候难道和发送文件的时候一样,直接用stat(sockfd)吗?

    ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count);
    7 replies  •  1970-01-01 08:00:00 +08:00
    yemoluo
    yemoluo
    Nov 27, 2013
    1
    这个有没有完是由socket来保证的
    Sherlockhlt
    Sherlockhlt
    OP
    Nov 27, 2013
    2
    @GTim
    但是我调用sendfile接收文件需要传入count参数,这个怎么获得?
    Sherlockhlt
    Sherlockhlt
    OP
    Nov 27, 2013
    3
    顶一下
    yemoluo
    yemoluo
    Dec 2, 2013
    5
    @Sherlockhlt 建议你去看一下源码...你就会一目了然了
    Sherlockhlt
    Sherlockhlt
    OP
    Dec 2, 2013
    6
    @GTim
    不用看了,linux不支持sendfile接收文件
    yemoluo
    yemoluo
    Dec 2, 2013
    7
    @Sherlockhlt 汗,看了你的回复,终于知道你要什么了,我了个去啊
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1016 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 22:44 · PVG 06:44 · LAX 14:44 · JFK 17:44
    ♥ Do have faith in what you're doing.