SOC_Connect

C Specification

#include <nitroWiFi/soc.h>
int SOC_Connect ( int s, const void* sockAddr );

Arguments

s Socket descriptor.
sockAddr The pointer to the socket address structures (SOCSockAddr and SOCSockAddrIn) that keep the partner addresses.

Return Values

0 or higher Successful.
SOC_EINPROGRESS Connection is not completed yet. (SOC_NONBLOCK is set to the socket descriptor, and the connection is established asynchronously.)
SOC_EINVAL Invalid processing.
SOC_EISCONN The socket is already connected.
SOC_EMFILE Cannot create any more socket descriptors.
SOC_ENETRESET Socket is not initialized.
SOC_ENOBUFS Insufficient resources.
SOC_ETIMEDOUT TCP connection timeout.

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

Description

This function uses the configuration value saved in the socket structure by SOC_Bind() to attempt a connection to the specified socket. If the socket is not yet bound to a local address, the socket is bound to an unused local address by SOC_Connect().

For SOC_SOCK_STREAM(TCP) sockets, SOC_Connect() always blocks until a connection is established. If the socket was set to non-blocked mode with SOC_Fcntl(), SOC_Connect() returns as soon as possible.

With SOC_SOCK_DGRAM sockets, SOC_Connect() sets the socket partner's address. No connection is made. Datagrams sent with subsequent SOC_Send() all go to the specified partner's address. Also subsequent SOC_Recv() functions receive only datagrams from the specified partner's address. If sockAddr is that protocol's null address, the socket partner address is reset.

See Also

SOC_Socket SOC_Bind, SOC_Recv, SOC_Send, SOC_Fcntl

Revision History

09/13/2005 Initial version.
01/13/2006 Edited return values.