_beginthreadx and socket
<p>i have a question about the _beginthreadx function In the third and fourth parameter:</p>

<p>if i have this line to create the thread</p>

<pre><code>hThread=(HANDLE)_beginthreadex(0,0, &amp;RunThread, &amp;m_socket,CREATE_SUSPENDED,&amp;threadID );
</code></pre>

<p><code>m_socket</code> is the socket that i want inside the thread (fourth parameter)</p>

<p>and i have the RunThread function (third parameter) in this way</p>

<pre><code>static unsigned __stdcall RunThread (void* ptr) {
    return 0;
}
</code></pre>

<p>It is sufficient to create the thread independently if m_socket has something or not?</p>

<h2>Thanks in advance</h2>

<p>Thank you for the response Ciaran Keating helped me understand better the thread</p>

<p>I'll explain a little more the situation</p>

<p>I´m creating the tread in this function inside a class</p>

<p>public: void getClientsConnection()
    {
        numberOfClients = 1;
        SOCKET temporalSocket = NULL;
        firstClient = NULL;
        secondClient = NULL;</p>

<pre><code>    while (numberOfClients &lt; 2)
    {
        temporalSocket = SOCKET_ERROR;
        while (temporalSocket == SOCKET_ERROR)
        {
            temporalSocket = accept(m_socket, NULL, NULL);
            //-----------------------------------------------
            HANDLE hThread;
             unsigned threadID;

            hThread=(HANDLE)_beginthreadex(0,0, &amp;RunThread, &amp;m_socket,CREATE_SUSPENDED,&amp;threadID );
            WaitForSingleObject( hThread, INFINITE );
                                if(!hThread)
                                     printf("ERROR AL CREAR EL HILO: %ld\n", WSAGetLastError());
                                //-----------------------------------------------

        }
        if(firstClient == NULL)
        {
            firstClient = temporalSocket;
            muebleC1 = temporalSocket;
            actionC1 = temporalSocket;
            ++numberOfClients;
            printf("CLIENTE 1 CONECTADO\n");
        }
        else
        {
            secondClient = temporalSocket;
            muebleC2 = temporalSocket;
            actionC2 = temporalSocket;
            ++numberOfClients;
            printf("CLIENTE 2 CONECTADO\n");
        }
    }
}
</code></pre>

<p>What i'm trying to do is to have the socket inside the thread while wait for a client connection</p>

<p>Is this feasible as i have the code of the thread?</p>

<p>I can change the state of the thread that is not a problem</p>

<p>Thanks again</p>
