Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: a7268c5f7ec719bc00b67ddb46c0c70df75c6c10
Ticket: 219298ffffffffffffffffffffffffffffffffff
socket -async behaves differently on Win95 and NT
User & Date: nobody on 2000-10-26 05:10:20
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    OriginalBugID: 2634 Bug
    Version: 8.2
    SubmitDate: '1999-08-31'
    LastModified: '2000-04-14'
    Severity: LOW
    Status: UnAssn
    Submitter: techsupp
    ChangedBy: hobbs
    RelatedBugIDs: 1776
    OS: Windows NT
    Machine: X86
    FixedDate: '2000-10-25'
    ClosedDate: '2000-10-25'
    
    
    Name:
    Waidelich
    
    Comments:
    winsock reports the failed close correctly. only a peer 'shutdown' is
        not reported correctly.
        
        I want Tcl to become cleaner every release. Workarounds are a real pain.
    
    ReproducibleScript:
    # SOCKET BUG (Win95 and NT?) is portability problem
        # =================================================
        # checked with Tcl 8.0.3, 8.0.4, 8.1.0 and 8.2.0
        # reported to Scriptics when 8.0.3 was released
        #
        # test-script follows
        #
        # connect to non-existent port fails without error report
        # fconfigure -error does not work on Win95 and only half on WinNT (no
        posix)
        # there is a workaround (fconfigure -peername)
        #
        #
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        # QUESTION: shouldn't a failed connect be reported by a READable
        socket?
        # I think this is how it worked with C on SCO-UNIX. the read can then
        # reports the error. A WRITEable socket does not mean
        # we have data to send. So no system call, no error report...
        #
        
        wm geometry . +300+10
        
        text .t -yscrollcommand ".s set" -bg yellow -width 60 -height 25
        scrollbar .s  -command ".t yview"
        
        pack .s -side right -fill y
        pack .t -fill both -expand yes
        
        proc debug  t {
        .t insert end "$t\n"
        .t see end
        update idletasks
        }
        
        proc rrr sock {
        debug "$sock readable"
        catch {read $sock} x
        global errorCode
        debug "read <$x> errno=$errorCode"
        }
        
        proc www sock {
        debug "$sock writable"
        global errorCode
        # from the manual: ...determine if an asynchronous connect operation
        succeeded.
        # I expected to get ECONNREFUSED (winsock 10061)
        # but got nothing
        catch {fconfigure $sock -error} r
        debug "-error <$r> <$errorCode>"
        # A workaround gives ENOTCONN --> I coude fake a ECONNREFUSED to user
        catch {fconfigure $sock -peername} r
                debug "-peername <$r> <$errorCode>"
        #
        fileevent $sock writable {} ;# don't loop
        #
        catch {close $sock} r
        debug "close <$r> <$errorCode>"
        }
        
        proc ccc {} {
        debug "connecting to localhost:6666 (change if exists!)"
        set sock [socket -async localhost 6666]
        debug "$sock opened"
        fconfigure $sock -blocking no
        fileevent $sock readable "rrr $sock"
        fileevent $sock writable "www $sock" ;# writeable on connect!
        debug "waiting for fileevents..."
        }
        
        ccc ;# connect now
        
        #from the log:
        #==============
        # connecting to localhost:6666 (change if exists!)
        # sock14 opened
        # waiting for fileevents...
        # sock14 writable
        # 95: -error <> <>
        # NT: -error <connection refused> <>     ... no POSIX in errno
        #
        # -peername <can't get peername: socket is not connected> <POSIX
        ENOTCONN {socket is not connected}>
        # close <> <POSIX ENOTCONN {socket is not connected}>
    
    ObservedBehavior:
    async connect gets reported differently on Win95 and NT
        
        although there is a workaround, it should be done how it was
        intended by the socket-abstraction
    
    DesiredBehavior:
    on failed async connect I expect the socket to become readable (and
        maybe writeable too?)
        
        on success I expect it to become writeable. And readable only if data is
        available.
    
    
    
    
    
  4. foundin changed to: "obsolete: 8.2"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "63. (unused)"
  10. title changed to: "socket -async behaves differently on Win95 and NT"
  11. type changed to: "Bug"