--- a/Socket.st Wed Feb 19 20:40:49 2020 +0100
+++ b/Socket.st Wed Feb 19 23:33:29 2020 +0100
@@ -16,10 +16,10 @@
"{ NameSpace: Smalltalk }"
NonPositionableExternalStream subclass:#Socket
- instanceVariableNames:'domain socketType protocol port peer peerName listening'
- classVariableNames:''
- poolDictionaries:''
- category:'Streams-External'
+ instanceVariableNames:'domain socketType protocol port peer peerName listening'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Streams-External'
!
!Socket primitiveDefinitions!
@@ -1770,23 +1770,6 @@
Return the number of bytes sent."
^ self nextPutBytes:aStringOrByteArray size from:aStringOrByteArray startingAt:1.
-!
-
-waitForConnection:secondsOrTimeDurationOrNil
- "wait for the connection secondsOrTimeDurationOrNil.
- Return true if connected"
-
- self readWaitWithTimeout:secondsOrTimeDurationOrNil.
- ^ self isConnected
-
- "Created: / 17-02-2020 / 20:02:53 / Stefan Vogel"
-!
-
-waitForConnectionUntil:aTimestamp
- "return true if connected"
-
- self readWaitWithTimeoutMs: (aTimestamp millisecondDeltaFrom:Timestamp now).
- ^ self isConnected
! !
!Socket methodsFor:'accepting connections'!
@@ -4516,6 +4499,38 @@
!Socket methodsFor:'waiting'!
+waitForConnection:secondsOrTimeDurationOrNil
+ "wait for the connection secondsOrTimeDurationOrNil.
+ Return true if connected"
+
+ self readWaitWithTimeout:secondsOrTimeDurationOrNil.
+ ^ self isConnected
+
+ "Created: / 17-02-2020 / 20:02:53 / Stefan Vogel"
+!
+
+waitForConnectionUntil:aTimestamp
+ "return true if connected"
+
+ self readWaitWithTimeoutMs: (aTimestamp millisecondDeltaFrom:Timestamp now).
+ ^ self isConnected
+!
+
+waitForConnectionWithErrorOnTimeout:secondsOrTimeDurationOrNil
+ "wait for the connection secondsOrTimeDurationOrNil.
+ Raise an error if not connected."
+
+ self readWaitWithTimeout:secondsOrTimeDurationOrNil.
+ self isConnected ifFalse:[
+ OpenError
+ raiseRequestWith:self
+ errorString:('Failed to connect to: %1 timeout:%2'
+ bindWith:self getPeer with:secondsOrTimeDurationOrNil).
+ ].
+
+ "Created: / 19-02-2020 / 22:55:04 / Stefan Vogel"
+!
+
waitForNewConnectionOrDataOnAny:otherConnections timeout:secondsOrTimeDurationOrNil
"suspend the current process, until either a new connection comes
in at the receiver, or data arrives on any of the otherConnections.
@@ -4586,7 +4601,7 @@
waitForNewConnectionWithTimeout:secondsOrTimeDurationOrNil
"suspend the current process, until a new connection comes
- in at the receiver or a timeout occurs.
+ in at the listening receiver or a timeout occurs.
For a new connection, an accept is performed and the new socket is returned.
Returns nil, if a timeout occurred.
This method implements the inner wait-primitive of a single-connection
@@ -4613,6 +4628,7 @@
^ newSock
"Modified (format): / 19-01-2018 / 18:53:15 / stefan"
+ "Modified (comment): / 19-02-2020 / 23:32:32 / Stefan Vogel"
! !
!Socket class methodsFor:'documentation'!