Syntax
int vm_soc_select(
    int nfds, 
    fd_set* readfds, 
    fd_set* writefds, 
    fd_set* exceptfds, 
    const timeval* timeout
);
ContentsIndex
PreviousUpNext
vm_soc_select
Example
Syntax
int vm_soc_select(
    int nfds, 
    fd_set* readfds, 
    fd_set* writefds, 
    fd_set* exceptfds, 
    const timeval* timeout
);
Description

Allows the application to query the status of multiple sockets. If timeout is null, vm_soc_select() will wait indefinitely until the first socket is ready. If both tv_sec and tv_msec are zero, vm_soc_select() will timeout immediately for polling the sockets in the set. in:

  1. If listen has been called and a connection is pending, accept will succeed.
  2. Data is available for reading (includes OOB data if VM_SOC_OOBINLINE is enabled).
  3. Connection has been closed/reset/terminated

out:

  1. If processing a connect request (non-blocking mode), connection has succeeded.
  2. Data can be sent.

ex: If processing a connect request (non-blocking mode), connection attempt failed. OOB data is available for reading (only if VM_SOC_OOBINLINE is disabled). Useful Macros: FD_ZERO(fd_set) Reset fd_set. FD_SET(s, fd_set) Add a particular socket with ID of s to fd_set. FD_CLR(s, fd_set) Remove a particular socket with ID of s from fd_set. FD_ISSET(s, fd_set) Non-zero if s is a member of the fd_set (s is ready). Otherwise, zero.

Parameters
Parameters 
Description 
int nfds 
[IN] The highest-numbered socket descriptor in any of the three sets, plus 1. 
fd_set* readfds 
[IN] Set of socket descriptors for read. 
fd_set* writefds 
[IN] Set of socket descriptors for write. 
fd_set* exceptfds 
[IN] Set of socket descriptors for exceptions. 
const timeval* timeout 
[IN] Specifies the timeout value. timeout == NULL: block until ready. timeout != NULL && value == 0: return immediately. timeout != NULL && value != 0: return after timeout. 
Return Values
Return Values 
Description 
Non-negative number 
The number of ready sockets.
 
Zero 
The timeout expires before anything interesting happens.
 
VM_SOC_INVALID_SOCKET 
Invalid socket ID.
 
VM_SOC_INVAL 
Socket is not calling soc_listen.
 
VM_SOC_WOULDBLOCK 
Non-blocking.
 
VM_SOC_BEARER_FAIL 
Bearer broken.
 
VM_SOC_ERROR 
Unspecified error. 
Example
 timeval timeout;
 fd_set writefds;
 timeout.tv_sec = 0;
 timeout.tv_usec = 2000;
 FD_ZERO(&writefds);
 FD_SET((bf_u32)sockIds[sock].id, &writefds);
 if (vm_soc_select(sockIds[sock].id+1, 0, &writefds, 0, &timeout) >= 0)
 {
    if (FD_ISSET(sockIds[sock].id, &writefds))
    {
        //socket is ready for writting data
    }
 }
File

vmsock.h

Group
Created with a commercial version of Doc-O-Matic. In order to make this message disappear you need to register this software. If you have problems registering this software please contact us at support@toolsfactory.com.