Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: b5fe37a4a91a29ae7f3fb981b92b9f7bc82568ae321cff12dfd5015b488deeb9
Ticket: 251f46655c1a8b588b01f00f43c435c04ad10c75
close of a pending socket -async fails and loses the buffered output
User & Date: serhiy.storchaka on 2026-10-16 21:08:27
Changes

  1. cmimetype changed to: "text/x-fossil-wiki"
  2. comment changed to:
    On Unix, closing a <nowiki>[socket -async]</nowiki> channel while the connection is still being established loses the data written to it:
    
    <verbatim>
    set s [socket -async $host $port]   ;# connect still pending
    puts $s hello
    close $s   ;# error: transport endpoint is not connected; the server gets nothing
    </verbatim>
    
    The same happens for a non-blocking channel, where the error is also raised by close.
    
    8.6 sends the data. Since [d5bc305ad2] Tcl_Close() always shuts down the read side before flushing, and TcpClose2Proc() calls shutdown(SHUT_RD) on the still connecting socket, which aborts the connect on Linux.
    
  3. login: "serhiy.storchaka"
  4. title changed to:
    close of a pending socket -async fails and loses the buffered output