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

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

  •  
  •   Sherlockhlt · Nov 26, 2013 · 3397 views
    This topic created in 4577 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   ·   Solana   ·   5747 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 03:28 · PVG 11:28 · LAX 20:28 · JFK 23:28
    ♥ Do have faith in what you're doing.