Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.protocols.tcp-ip    |    TCP and IP network protocols.    |    14,669 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 13,018 of 14,669    |
|    Jorgen Grahn to All    |
|    shutdown(2) and TCP socket buffers    |
|    28 Aug 09 20:41:36    |
   
   From: grahn+nntp@snipabacken.se   
      
   Partly to draw attention away from the recent irrelevant, off-topic   
   heavily cross-posted trolling:   
      
   What is the BSD socket call shutdown(fd, SHUT_RD) supposed to do to   
   a TCP socket, really? I have a short program where I do   
      
    fd_ = socket(ai.ai_family, ai.ai_socktype, ai.ai_protocol);   
    if(fd_==-1) return false;   
      
    (void)setsockopt(fd_, SOL_SOCKET, SO_SNDBUF,   
    &bufsize_, sizeof bufsize_);   
      
    int rc = ::connect(fd_, ai.ai_addr, ai.ai_addrlen);   
    if(rc==-1) {   
    /* ... */   
    return false;   
    }   
      
    rc = fcntl(fd_, F_SETFL, O_NONBLOCK);   
    assert(!rc);   
      
    rc = shutdown(fd_, SHUT_RD);   
    assert(!rc);   
      
   but at least under Linux, the peer can happily write to me. 'netstat'   
   shows my RX buffer growing and growing. I assume it will fill up   
   eventually, but that buffer is 64k or something like that.   
      
   I haven't tried reading from the socket. I assume I will not be   
   awoken from select, nor be able to read anything.   
      
   This isn't a /problem/ for me, just surprising. I would have expected   
   my side to claim its TCP window is closed -- and maybe save several   
   dozen kilobytes of buffer space per socket.   
      
   /Jorgen   
      
   --   
    // Jorgen Grahn
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca