Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 9544bec5870aa31a6ab79a7231fceb52d0f39d75
Ticket: 10dc6daa375d45051a3c6064cbc1b32686bc1745
Tcl_Gets() fails to read non-blocking socket
User & Date: anonymous on 2014-10-16 08:28:44
Changes

  1. icomment:
    Here are two plain TCL scripts which show the problem on Linux/Opensuse 13.1 and on Windows 7.  When running via 8.5.16/8.5.17rc the client stops rather quickly.
    When running against 8.5.15 or 8.6.1 the clients reads data as expected.
    
    Server:
    # ----------------------------
    socket -server accept 65422
    proc accept {chan addr port} {
        fconfigure $chan -buffering none -translation binary
        while {![catch {
            after 1
            puts $chan "R4C7C W4C7C"
            after 7
            puts $chan "R46D0 W46D0"
            after 6
            puts $chan "R47AC W47AC"
            after 6
            puts $chan "A01BDD10FC07D21C188E2C27D1CC37D1D"
            after 0
            puts $chan "A01BDD2B0C07D22C188E4C27D1DC37D1E"
        }]} {
            # nothing
        }
    }
    vwait forever
    # ----------------------------
    
    Client
    # ----------------------------
    set fd [socket localhost 65422]
    fconfigure $fd -blocking 0 -translation binary -buffering none
    
    fileevent $fd readable [list read_socket $fd]
    
    set last 0
    proc read_socket {fd} {
        set now [clock milliseconds]
        gets $fd line
        if {[eof $fd]} {
            close $fd
            return
        }
        if {$line ne ""} {
            puts "$now [expr {$now-$::last}] $line"
            set ::last $now
        }
    }
    vwait forever
    # ----------------------------
    
  2. login: "anonymous"
  3. mimetype: "text/plain"