STCP/network_io_tcp.c
ssize_t _network_send_packet(network_context_t *ctx,
                             const void *src, size_t len)
{
    network_context_socket_tcp_t *tcp_io_ctx;
    uint16_t packet_len;    /* network byte order */

    assert(ctx && src);
    assert(ctx->peer_addr_len > 0);

    tcp_io_ctx = (network_context_socket_tcp_t *) ctx->impl_data;
    assert(tcp_io_ctx);

    VERIFY_SOCKET(ctx);
    DEBUG_PEER(ctx);

    if (_tcp_connect(ctx) < 0)
        return -1;

    packet_len = htons(len);
    if (_tcp_io(GET_SOCKET(ctx), &packet_len, sizeof(packet_len),
                (io_func_t) write) < 0 ||
        _tcp_io(GET_SOCKET(ctx), (void *) src, len, (io_func_t) write) < 0)
        return -1;

    return len;
}
/* send the given packet to the peer */
send the given packet to the peer
send the given packet to the peer
ssize_t _network_send_packet(network_context_t *ctx,
                             const void *src, size_t len)
{
    network_context_socket_tcp_t *tcp_io_ctx;
    uint16_t packet_len;    
    assert(ctx && src);
    assert(ctx->peer_addr_len > 0);
    tcp_io_ctx = (network_context_socket_tcp_t *) ctx->impl_data;
    assert(tcp_io_ctx);
    VERIFY_SOCKET(ctx);
    DEBUG_PEER(ctx);
    if (_tcp_connect(ctx) < 0)
        return -1;
    packet_len = htons(len);
    if (_tcp_io(GET_SOCKET(ctx), &packet_len, sizeof(packet_len),
                (io_func_t) write) < 0 ||
        _tcp_io(GET_SOCKET(ctx), (void *) src, len, (io_func_t) write) < 0)
        return -1;
    return len;
}
ssize_t _network_send_packet ( network_context_t * ctx , const void * src , size_t len ) { network_context_socket_tcp_t * tcp_io_ctx ; uint16_t packet_len ; assert ( ctx && src ) ; assert ( ctx -> peer_addr_len > 0 ) ; tcp_io_ctx = ( network_context_socket_tcp_t * ) ctx -> impl_data ; assert ( tcp_io_ctx ) ; VERIFY_SOCKET ( ctx ) ; DEBUG_PEER ( ctx ) ; if ( _tcp_connect ( ctx ) < 0 ) return -1 ; packet_len = htons ( len ) ; if ( _tcp_io ( GET_SOCKET ( ctx ) , & packet_len , sizeof ( packet_len ) , ( io_func_t ) write ) < 0 || _tcp_io ( GET_SOCKET ( ctx ) , ( void * ) src , len , ( io_func_t ) write ) < 0 ) return -1 ; return len ; }
send the given packet to the peer
send the given packet to the peer
/* network byte order */