Ejemplo n.º 1
0
/* return 0 on success.
 * return -1 on failure.
 */
int kill_tcp_connection_to(TCP_Connections *tcp_c, int connections_number)
{
    TCP_Connection_to *con_to = get_connection(tcp_c, connections_number);

    if (!con_to)
        return -1;

    unsigned int i;

    for (i = 0; i < MAX_FRIEND_TCP_CONNECTIONS; ++i) {
        if (con_to->connections[i].tcp_connection) {
            unsigned int tcp_connections_number = con_to->connections[i].tcp_connection - 1;
            TCP_con *tcp_con = get_tcp_connection(tcp_c, tcp_connections_number);

            if (!tcp_con)
                continue;

            if (tcp_con->status == TCP_CONN_CONNECTED) {
                send_disconnect_request(tcp_con->connection, con_to->connections[i].connection_id);
            }

            --tcp_con->lock_count;
        }
    }

    return wipe_connection(tcp_c, connections_number);
}
Ejemplo n.º 2
0
/* return 0 on success.
 * return -1 on failure.
 */
int kill_tcp_connection_to(TCP_Connections *tcp_c, int connections_number)
{
    TCP_Connection_to *con_to = get_connection(tcp_c, connections_number);

    if (!con_to)
        return -1;

    //TODO
    return wipe_connection(tcp_c, connections_number);
}