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

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

  •  
  •   Sherlockhlt · Nov 26, 2013 · 3676 views
  •   You need to sign in to view this topic
    This topic created in 4711 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
        1
    yemoluo  
       Nov 27, 2013
    这个有没有完是由socket来保证的
    Sherlockhlt
        2
    Sherlockhlt  
    OP
       Nov 27, 2013
    @GTim
    但是我调用sendfile接收文件需要传入count参数,这个怎么获得?
    Sherlockhlt
        3
    Sherlockhlt  
    OP
       Nov 27, 2013
    顶一下
    yemoluo
        5
    yemoluo  
       Dec 2, 2013
    @Sherlockhlt 建议你去看一下源码...你就会一目了然了
    Sherlockhlt
        6
    Sherlockhlt  
    OP
       Dec 2, 2013
    @GTim
    不用看了,linux不支持sendfile接收文件
    yemoluo
        7
    yemoluo  
       Dec 2, 2013
    @Sherlockhlt 汗,看了你的回复,终于知道你要什么了,我了个去啊
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   3300 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 12:30 · PVG 20:30 · LAX 05:30 · JFK 08:30
    ♥ Do have faith in what you're doing.