next up previous contents index
Next: Error codes. Up: Socket I/O Previous: Stream-oriented, character-at-a-time interface.   Contents   Index

Socket-probing.

With the help of the predicate socket_select/6 one can establish a group of asynchronous or synchronous socket connections. In the synchronous mode, this call is blocked until one of the sockets in the group becomes available for reading or writing, as described below. In the asynchronous mode, this call is used to probe the sockets periodically, to find out which sockets have data available for reading or which sockets have room in the buffer to write to.

The directory XSB/examples/socket/select/ has a number of examples of the use of the socket-probing calls.

socket_select(+SymConName,+Timeout,-ReadSockL,-WriteSockL,-ErrSockL,?ErrorCode)

SymConName must be an atom that denotes an existing connection group, which must be previously created with socket_set_select/4 (described below). ReadSockL, WriteSockL, ErrSockL are lists of socket handles (as returned by socket/2) that specify the available sockets that are available for reading, writing, or on which exception conditions occurred. Timeout must be an integer that specifies the timeout in seconds (0 means probe and exit immediately). If Timeout is a variable, then wait indefinitely until one of the sockets becomes available.

socket_set_select(+SymConName,+ReadSockFdLst,+WriteSockFdLst,+ErrorSockFdLst)

Creates a connection group with the symbolic name SymConName (an atom) for subsequent use by socket_select/6. ReadSockFdLst, WriteSockFdLst, and ErrorSockFdLst are lists of sockets for which socket_select/6 will be used to monitor read, write, or exception conditions.

socket_select_destroy(+SymConName)

Destroys the specified connection group.


next up previous contents index
Next: Error codes. Up: Socket I/O Previous: Stream-oriented, character-at-a-time interface.   Contents   Index
Luis Fernando P. de Castro 2003-06-27