so_cancel()

The socket call cancels a pending blocking sockets API call on a socket.

Syntax

#include <types.h>
#include <sys\socket.h>
int so_cancel (s)
int s;

Parameters

s

Description

The so_cancel() call is used in multithreaded applications where one thread needs to 'wake up' another thread which is blocked in a sockets API call.

The thread that has been 'awakened' will return a value of -1 from the sockets API call, and the error will be set to SOCEINTR. If multiple threads are blocked on the same socket and so_cancel() is issued for that socket, only one of the threads will be 'awakened.'

When a socket is in blocking mode, if no threads are blocking on the socket when so_cancel() is issued, the next sockets API call to be issued on that socket will return SOCEINTR. When a socket is in nonblocking mode and no threads are blocking on the socket when so_cancel() is issued, the next call to select() that includes the socket will return SOCEINTR.

Return Values

The value 0 indicates success; the value -1 indicates an error. You can get the specific error code by calling sock_errno() or psock_errno().

Error Code

SOCENOTSOCK


[Back: shutdown()]
[Next: sock_errno()]