 <p>You need to remove the <code>&amp;</code> operator when passing the <code>client</code> variable to the <code>lpParameter</code> param of <code>CreateThread()</code>:</p> <pre><code>//CreateThread(..., &amp;client, ...); CreateThread(..., client, ...); </code></pre> <p><code>SendToPeer()</code> is expecting to receive a <code>Peer*</code> pointer but you are actually sending it a <code>Peer**</code> pointer instead.</p>