--- /home/andreask/trans/Chan.tcl	2009-07-28 15:14:06.000000000 -0700
+++ ./Chan.tcl	2009-07-28 15:13:35.000000000 -0700
@@ -58,6 +58,19 @@
 	    Debug.chan {$mychan read $chan $n -> [string map {\n \\n} "[string length $result] bytes '[string range $result 0 20]...[string range $result end-20 end]"]'}
 	}
 
+	Debug.chan {$mychan read $chan eof     = [chan eof     $chan]}
+	Debug.chan {$mychan read $chan blocked = [chan blocked $chan]}
+
+	# ![chan configure $chan -blocking] - optimization -> save the
+	# -blocking information in a flag, as it passes through method
+	# 'blocking'.
+	if {![string length $result] &&
+	    ![chan configure $chan -blocking] &&
+	    ![chan eof $chan]} {
+	    #return -code error -11 ; # EAGAIN
+	    return -code error EAGAIN
+	}
+
 	return $result
     }
 
@@ -70,7 +83,7 @@
     # Setting up, shutting down.
     method initialize {mychan mode} {
 	Debug.chan {$mychan initialize $chan $mode ([::chan configure $chan])}
-	::chan configure $chan -blocking 0 -buffering none -encoding binary -eofchar {{} {}} -translation {binary binary}
+	::chan configure $chan -buffering none -encoding binary -eofchar {{} {}} -translation {binary binary}
 	return [list initialize finalize blocking watch read write]
     }
 
