Tcl Source Code

Artifact [56dac3657d]
Login

Artifact 56dac3657d5db3b4c7ce46324fd4b2c34e21a676:

Attachment "socket_crash.itcl" to ticket [3301634fff] added by tombert 2011-05-13 22:15:34.
if {[info command socket_crash] == {}} {
    class socket_crash {
        constructor {args} {}
        destructor {}

        ## creation
        public method close {args}
        public method shutdown {}


        ## connection related
        public method isConnected {}
        public variable stateVar {}
        public variable stateHandler {}
        public variable port {}
        public variable host {}
        public variable fileHandler {}
        public variable fileEvents 1
        public variable syncSleep 10
        public variable loggingTitle {}

        ## connection handlers
        protected variable serverSocket {}
        protected variable clientSocket {}
        protected variable socketOptions
        protected variable isWritable 0     ;# set when socket becomes writable
        protected variable isReadable 0     ;# set when socket becomes readable
        protected variable isCanceled 0     ;# state if request has been canceled
        protected method triggerWritable {set timeoutId socket}    ;## disables fileevents and sets isWritable
        protected method triggerReadable {set timeoutId socket}    ;## disables fileevents and sets isReadable
        ## helpers
        #protected variable bufferCompObj {}

	public method Log {level text args} {
	    crashtest
	    #getclock -float
	}
    }
}
    proc lgetclock {args} {
	return
        set doFloat 0
        set refTime 0.0
        for {set index 0} {$index < [llength $args]} {incr index} {
            set item [lindex $args $index]
            switch -exact -- $item {
                "-float" {set doFloat 1}
                "-ref" {
                    set refTime [lindex $args $index+1]
                    if {![string is double -strict $refTime]} {error "getclock: -refTime not a double value '$refTime'"}
                }
            }
        }
        if {$doFloat} {
            return [expr {[clock milliseconds] / 1000. - $refTime}]
        } else {
            set time [expr {round([clock milliseconds] - $refTime * 1000.)}]
            return [list [expr {entier($time / 1000.)}] [expr {$time % 1000}]]
        }
    }

body socket_crash::constructor {args} {
    getclock -float
}

body socket_crash::destructor {} {
    Log d "socket_crash$this:destructor"

    shutdown
    close
}

body socket_crash::close {args} {
    return
}
body socket_crash::shutdown {} {
    return
}