TutSocketGetBlockMode


Name

TutSocketGetBlockMode — get the block mode of a socket

Synopsis

T_BOOL TutSocketGetBlockMode(socket_fd, block_mode_return) 
T_INT4 socket_fd; 
T_BOOL *block_mode_return; 

Arguments

socket_fd — socket file descriptor to get block mode for

block_mode_return — pointer to storage for block mode

Return Values

TRUE if block mode was successfully retrieved from socket, FALSE otherwise.

Diagnostics

If TutSocketGetBlockMode fails, it returns FALSE and sets the global SmartSockets error number to one of:

Description

TutSocketGetBlockMode gets the block mode of a socket by calling fcntl to get the appropriate socket status flag. The status flag is system-dependent and is one of O_NONBLOCK, O_NDELAY, or FNDELAY. The block mode controls the behavior of I/O operations that cannot complete immediately. The most common operations are sending and receiving data.

The default block mode is TRUE. In blocking mode, an attempt to send data to a socket does not finish until all data has been sent or an error occurs. An attempt to receive data from a socket does not finish until data has been received or an error occurs.

A block mode of FALSE is also known as non-blocking mode. In non-blocking mode, an attempt to send data to a socket finishes when all data (that can be sent immediately) is sent. An attempt to receive data from a socket finishes when all data (that can be received immediately) is received.

Caution

If TutSocketGetBlockMode returns FALSE, it does not store a value in block_mode_return.

See Also

TutSocketSetBlockMode; see the TIBCO SmartSockets Application Programming Interface reference for detailed information on TipcConnGetBlockMode.

Examples

This example gets the block mode of a socket and prints it:

if (!TutSocketGetBlockMode(socket_fd, &block_mode)) { 
  /* error */ 
}  
 
TutOut("The socket block mode is %d.\n", block_mode); 

TIBCO SmartSockets™ Utilities
Software Release 6.8, July 2006
Copyright © TIBCO Software Inc. All rights reserved
www.tibco.com