SOC_Fcntl

C Specification

#include <nitroWiFi/soc.h>
#define SOC_F_GETFL 3
#define SOC_F_SETFL 4
#define SOC_O_NONBLOCK 0x04
int SOC_Fcntl( int s, int cmd, int mode );

Arguments

s Socket descriptor.
cmd Command (SOC_F_*).
mode Value to be set or read.

Return Values

0 or higher Successful.
-1 Error.

Note: Additional errors may be generated and returned in future library releases. Please treat all negative return values as general errors.

Description

This function performs the following operations on the opened socket descriptor.

Commands Arguments Types Description
SOC_F_GETFL None Gets the socket descriptor's flag.
SOC_F_SETFL Logical sum of the SOC_O_* flag int Sets the socket descriptor's flag.

To set the socket descriptor to non-blocked mode, use the following code.

val = SOC_Fcntl(s, SOC_F_GETFL, 0);
SOC_Fcntl(s, SOC_F_SETFL, val | SOC_O_NONBLOCK);

To return the socket descriptor to blocked mode, use the following code.

val = SOC_Fcntl(s, SOC_F_GETFL, 0);
SOC_Fcntl(s, SOC_F_SETFL, val & ~SOC_O_NONBLOCK);

The socket descriptor is set to blocked mode by default.

See Also

SOC_Connect, SOC_Accept, SOC_Recv, SOC_Send

Revision History

09/13/2005 Initial version.