TutSocketCheck check if data can be read from or written to a socket
T_BOOL TutSocketCheck(socket_fd, check_mode, timeout
) T_INT4socket_fd
; T_IO_CHECK_MODEcheck_mode
; T_REAL8timeout
;
socket_fd
socket file descriptor to check
check_mode
how to check the socket availability
timeout
maximum number of seconds to wait for availability
TRUE
if data can be read/written, FALSE
if timeout reached or error occurred.
If TutSocketCheck fails, it returns FALSE
and sets the global SmartSockets error number to one of:
TutSocketCheck is a convenience function that provides a simplified interface to the select function. If check_mode
is T_IO_CHECK_READ, then TutSocketCheck checks if data is available to be read from the socket. If check_mode
is T_IO_CHECK_WRITE, then TutSocketCheck checks if data can be written to the socket without blocking. TutSocketCheck returns TRUE
if the socket is available and FALSE
otherwise. The timeout controls how long TutSocketCheck waits for availability. To wait indefinitely, use the constant T_TIMEOUT_FOREVER for the timeout. To poll the socket without blocking, use a timeout of 0
.
Server sockets may use TutSocketCheck to check if a client has connected.
None
This example uses TutSocketCheck to wait for up to 10 seconds for a new client to connect to a server socket, then accepts the new client with TutSocketAccept:
if (!TutSocketCheck(server_fd, T_IO_CHECK_READ, 10.0)) {/* error */
} else { client_fd = TutSocketAccept(server_fd); if (client_fd == -1) {/* error */
} }
TIBCO SmartSockets™ Utilities Software Release 6.8, July 2006 Copyright © TIBCO Software Inc. All rights reserved www.tibco.com |