AbstractOperatingSystem.st
changeset 18955 34d0eee1f6d9
parent 18745 89ae65c02a3e
child 18958 e35ab14763b6
child 18982 ca1ba3a8fa67
--- a/AbstractOperatingSystem.st	Wed Nov 25 19:42:31 2015 +0100
+++ b/AbstractOperatingSystem.st	Wed Nov 25 19:43:30 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'!