riot_sys::bindgen

Function sock_tcp_connect

Source
pub unsafe extern "C" fn sock_tcp_connect(
    sock: *mut sock_tcp_t,
    remote: *const sock_tcp_ep_t,
    local_port: u16,
    flags: u16,
) -> c_int
Expand description

@brief Establishes a new TCP sock connection

@pre sock != NULL @pre (remote != NULL) && (remote->port != 0)

@param[out] sock The resulting sock object. @param[in] remote Remote end point for the sock object. @param[in] local_port Local port for the connection. May be 0. * If local_port == 0 the connection is bound to a random port. @param[in] flags Flags for the sock object. See also @ref net_sock_flags. May be 0.

@return 0 on success. @return -EADDRINUSE, if (flags & SOCK_FLAGS_REUSE_EP) == 0 and @p local_port is already used elsewhere @return -EAFNOSUPPORT, if sock_tcp_ep_t::family of @p remote is not supported. @return -ECONNREFUSED, if no-one is listening on the @p remote end point. @return -EINVAL, if sock_tcp_ep_t::addr of @p remote is an invalid address. @return -EINVAL, if sock_tcp_ep_t::netif of @p remote is not a valid interface. @return -ENETUNREACH, if network defined by @p remote is not reachable. @return -ENOMEM, if system was not able to allocate sufficient memory to establish connection. @return -EPERM, if connections to @p remote are not permitted on the system (e.g. by firewall rules). @return -ETIMEDOUT, if the connection attempt to @p remote timed out.