On 05 Oct 2012, at 12:47, Santiago Bragagnolo <
santiagobragagnolo@gmail.com> wrote:
> Hi guys, theres something like the select or poll C functions in order to wait for incoming-data from a set of sockets? I searched at the list and in the pharo by example book without any success and i didn't find a method named poll / select ( select in terms of sockets ) in the image.
As far as I know there is no such primitive. It would be very nice to have though, it is one of the building blocks to do asynchroneous IO. But this is just one way to do polling.
> Maybe i need to spawn a process per socket?
Indeed, this would be the classic way to do it: just do a blocking read until ConnectionTimedOut and loop.
processNextResultSet: aConnection querySettings: aQuerySettings
"Gets the next resultSet of the query. Depending on the type of query, it will return a DBXResult or DBXResultSet.
If there is a timeout, it will cicle till this is finished."
| returnCode |
[self
nextResultSet: aConnection
querySettings: aQuerySettings
onReturn: [:handle :code |�
returnCode := code.
code = OpenDBX resultWithRows
ifTrue: [ ^ self processResultWithRows: aConnection
resultHandle: handle�
querySettings: aQuerySettings].
code = OpenDBX resultWithoutRows
ifTrue: [ ^ self processResultWithoutRows: aConnection
resultHandle: handle
querySettings: aQuerySettings].
code = OpenDBX resultDone ifTrue: [^ nil].
(code = OpenDBX resultTimeout) ifTrue: [ (Delay forMilliseconds: (aQuerySettings timeout asMiliseconds)) wait �].
]] doWhileTrue: [returnCode = OpenDBX resultTimeout].
OpenDBXDriverError signal: 'Uknown problem with executeStatement'.