CTL_STATUS_t ctl_tcp_connect(CTL_SOCKET_t s, CTL_NET_IPv4_ADDR_t remoteIpAddr, CTL_NET_PORT_t remotePort, CTL_TIME_t timeout);
ctl_tcp_connect connects socket s to port remotePort of remote host remoteIpAddr. The socket should have been previously allocated with ctl_tcp_socket.
Returns CTL_NO_ERROR if successful or an error code for fail (i.e. no sockets were available).
There is no non-blocking version of this function. If timeout is non-zero ctl_tcp_connect will block until the connection is made or it times out. If timeout is zero, ctl_tcp_connect will block for a few microseconds until the network task signals that it has started the connect process.
If you call ctl_tcp_connect with timeout set to zero, you can poll the connection state using ctl_tcp_get_socket_state to determine when the connect (or fail timeout) occurs.
ctl_tcp_connect must not be called in the zero-priority main task nor should it be called from the network task (in a UDP or TCP receive callback).