socket – Como fazer uma thread de um método da mesma classe?


Como eu posso executar esse método em paralelo?

void Network::Connection()
{
    close = false;
    std::string serverResponse;
    WSADATA wsaData;
    WSAStartup(MAKEWORD(2, 2), &wsaData);

    struct addrinfo* result = NULL, * ptr = NULL, hints;

    ZeroMemory(&hints, sizeof(hints));
    hints.ai_family = AF_UNSPEC;
    hints.ai_socktype = SOCK_STREAM;
    hints.ai_protocol = IPPROTO_TCP; //IPPROTO_UDP

    getaddrinfo(ip, port, &hints, &result);

    SOCKET ConnectSocket = INVALID_SOCKET;

    ptr = result;

    ConnectSocket = socket(ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol);
    connect(ConnectSocket, ptr->ai_addr, (int)ptr->ai_addrlen);

    freeaddrinfo(result);
    
    char recvbuf(512);
    int iResult;

    while (1) 
    {
        if (sendMessage) 
        {
            send(ConnectSocket, sendbuf, (int)strlen(sendbuf), 0);
            sendMessage = false;
            do
            {
                iResult = recv(ConnectSocket, recvbuf, sizeof(recvbuf), 0);
                if (iResult > 0)
                {
                    printf("Bytes received: %dn", iResult);
                    serverResponse.append(recvbuf, iResult - 2);
                    std::cout << serverResponse;
                }
                else if (iResult == 0)
                    printf("Connection closedn");
                else
                    printf("recv failed: %dn", WSAGetLastError());
            } while (iResult > 0);
        }   

        if (close)
            break;
    }

    shutdown(ConnectSocket, SD_SEND);
    closesocket(ConnectSocket);
    WSACleanup();
}

Ja tentei isso mas não consegui

void Network::StartConnection()
{
    //run connection async
    std::thread t1(&Network::Connection);
}