<commit_before>#include "clientconn.h"

ClientConn::ClientConn() {
    status = clientStatus::Closed;
    sock = nullptr;
}

ClientConn::ClientConn(QObject *parent) : QObject(parent) {
    new (this) ClientConn();
}

void ClientConn::start(QString name) {
    if (status != clientStatus::Closed) return;

    threadListener = new ClientConnListener();
    threadListener->start();

    status = clientStatus::Started;

    this->name = name;
}

bool ClientConn::connect(Conn server) {
    if (status != clientStatus::Started) return false;

    sock = new QTcpSocket();
    sock->connectToHost(server->addr, ServerClientPort);

    if (sock->waitForConnected(ConnectPackageTimeOut)) {
        auto fr = LRSBasicLayerFrame(LRSBasicLayerFrame::frameType::Data, QByteArray(name));
        sock->write(fr);

        status = clientStatus::Connected;
        while (threadListener->isRunning()) ;
        delete threadListener;
        threadListener = nullptr;

        return true;
    } else {
        delete sock;
        sock = nullptr;

        return false;
    }
}

void ClientConn::disconnect() {
    if (status != clientStatus::Connected) return;

    sock->disconnectFromHost();
    sock->close();

    delete sock;
    sock = nullptr;

    threadListener = new ClientConnListener();
    threadListener->start();

    status = clientStatus::Started;
}
<commit_msg>network fix.2<commit_after>#include "clientconn.h"

ClientConn::ClientConn() {
    status = clientStatus::Closed;
    sock = nullptr;
}

ClientConn::ClientConn(QObject *parent) : QObject(parent) {
    new (this) ClientConn();
}

void ClientConn::start(QString name) {
    if (status != clientStatus::Closed) return;

    threadListener = new ClientConnListener(this, this);
    threadListener->start();

    status = clientStatus::Started;

    this->name = name;
}

bool ClientConn::connect(Conn server) {
    if (status != clientStatus::Started) return false;

    sock = new QTcpSocket();
    sock->connectToHost(server->addr, ServerClientPort);

    if (sock->waitForConnected(ConnectPackageTimeOut)) {
        auto fr = LRSBasicLayerFrame(LRSBasicLayerFrame::frameType::Data, QByteArray(name));
        sock->write(fr);

        status = clientStatus::Connected;
        while (threadListener->isRunning()) ;
        delete threadListener;
        threadListener = nullptr;

        return true;
    } else {
        delete sock;
        sock = nullptr;

        return false;
    }
}

void ClientConn::disconnect() {
    if (status != clientStatus::Connected) return;

    sock->disconnectFromHost();
    sock->close();

    delete sock;
    sock = nullptr;

    threadListener = new ClientConnListener(this, this);
    threadListener->start();

    status = clientStatus::Started;
}

{'fraction_non_alphanumeric': 0.12644927536231884, 'fraction_numerical': 0.00036231884057971015, 'mean_word_length': 3.4035087719298245, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4080500', 'n_tokens_mistral': 814, 'n_tokens_neox': 783, 'n_words': 169}