Nonblocking I/O

When an application issues one of the socket input APIs and there is no data to read, the API blocks and does not return until there is data to read.

Similarly, an application can block on a socket output API when data cannot be sent immediately. Finally, connect() and accept() can block while waiting for connection establishment with the partner's programs.

Sockets provide a method that enables application programs to issue APIs that block so that the API returns without delay. This is done by either calling fcntl() to turn on the O_NONBLOCK flag, or calling ioctl() to turn on the FIONBIO flag. When running in this nonblocking mode, if an API cannot be completed without blocking, it returns immediately. A connect() might return with [EINPROGRESS], which means that the connection initiation has been started. You can then use the poll() or select() to determine when the connection has been completed. For all other APIs that are affected by running in the nonblocking mode, an error code of [EWOULDBLOCK] indicates that the call was unsuccessful.

You can use nonblocking with the following socket APIs:
  • accept()
  • connect()
  • gsk_secure_soc_read()
  • gsk_secure_soc_write()
  • read()
  • readv()
  • recv()
  • recvfrom()
  • recvmsg()
  • send()
  • send_file()
  • send_file64()
  • sendmsg()
  • sendto()
  • SSL_Read()
  • SSL_Write()
  • write()
  • writev()