/* This function is called when user wants to create a connection to a peer host.  */
static int winc1500_connect(struct net_context *context, const struct sockaddr *addr, socklen_t addrlen, net_context_connect_cb_t cb, int32_t timeout, void *user_data)
/* This function is called when user wants to create a connection to a peer host.  */
static int winc1500_connect(struct net_context *context, const struct sockaddr *addr, socklen_t addrlen, net_context_connect_cb_t cb, int32_t timeout, void *user_data)
{
	SOCKET socket = (int)context->offload_context;
	int ret;
	w1500_data.socket_data[socket].connect_cb = cb;
	w1500_data.socket_data[socket].connect_user_data = user_data;
	w1500_data.socket_data[socket].ret_code = 0;
	ret = connect(socket, (struct sockaddr *)addr, addrlen);
	if (ret) {
		LOG_ERR("connect error %d %s!",
			ret, socket_error_string(ret));
		return ret;
	}
	if (timeout != 0 &&
	    k_sem_take(&w1500_data.socket_data[socket].wait_sem, K_MSEC(timeout))) {
		return -ETIMEDOUT;
	}
	return w1500_data.socket_data[socket].ret_code;
}