AbstractOperatingSystem.st
branchjv
changeset 18958 e35ab14763b6
parent 18746 39bb2c6c0af5
parent 18955 34d0eee1f6d9
child 18983 9f3e91ff6418
--- a/AbstractOperatingSystem.st	Wed Nov 25 07:04:00 2015 +0100
+++ b/AbstractOperatingSystem.st	Thu Nov 26 06:54:35 2015 +0100
@@ -6747,6 +6747,34 @@
 
     "on select error, a read will immediately return, so answer true"
     ^ result > 0.
+!
+
+writeExceptionCheck:fd
+    "return true, if filedescriptor can be written without blocking
+     or has an exception event pending.
+     This is the case if data can be written to a filedescriptor
+     or the write would return an error.
+     This is actually only used with sockets, to wait for a connect to
+     be finished."
+
+    |result fdArray|
+
+    self supportsSelect ifFalse:[
+        "/ mhmh - what should we do then ?
+        "/ For now, return true as if data was present,
+        "/ and let the thread fall into the write.
+        "/ It will then (hopefully) be desceduled there and
+        "/ effectively polling for output.
+        ^ true
+    ].
+
+    result := self
+                selectOnAnyReadable:nil writable:(fdArray := Array with:fd) exception:fdArray
+                readableInto:nil writableInto:nil exceptionInto:nil
+                withTimeOut:0.
+
+    "on select error, a read will immediately return, so answer true"
+    ^ result > 0.
 ! !
 
 !AbstractOperatingSystem::PrinterInfo class methodsFor:'constants'!