<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[DLL-Problem mit CSocket]]></title><description><![CDATA[<p>Nachdem ich nun stundenlang gegoogled habe, denke ich mein Problem soweit erkannt zu haben...</p>
<p>Ich habe ein Programm geschrieben, das Daten von einem Server über einen Socket erhält. Wir gehen eine Verbindung zum Server ein, loggen uns ein und erhalten Daten...<br />
Als .exe funktioniert es zumindest. Umgewandelt als dll scheitert es allerdings.</p>
<p>Das empfangen der Daten soll in einem Thread passieren (was vermutlich das Problem ist!)</p>
<pre><code class="language-cpp">UINT CRTclient::MyThreadProc(LPVOID pParam)
{
    CSocket *refreshSocket = new CSocket();
    CAsyncSocket *acceptSocket;
    int reply;
    char *inByte = 0;
    char **lines;
    int *lineCount;
    int err = 0;	
	CString sockAddress;
	UINT portAddress;

	lineCount = (int*)malloc(sizeof(int));
    acceptSocket = new(CAsyncSocket);

	if (!AfxSocketInit())
	{
		AfxMessageBox(&quot;IDP_SOCKETS_INIT_FAILED&quot;);
		return FALSE;
	}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//************************************************************************************************************//
// Die scheiternde Zeile:
    if (!acceptSocket-&gt;Create(9058)) // we let windows find a good port 9058
    {
        err = acceptSocket-&gt;GetLastError(); //just for debugging
        return NET_CREATEERROR; 
    }
    // we get the assigned port address
    if (0 == acceptSocket-&gt;GetSockName(sockAddress, portAddress))
    {
        err = acceptSocket-&gt;GetLastError(); //just for debugging
        return NET_GETPORTERROR; 
    }
    refreshPort = (int)portAddress;  //we communicate the port address to the main thread ...
	refreshPort = 25123;
	err = acceptSocket-&gt;Listen(5);
    if (0 == err) // no waiting partner
	{
		err = acceptSocket-&gt;GetLastError();
        return NET_ACCEPTERROR; 
	}
    if (!acceptSocket-&gt;Accept(*refreshSocket)) // no waiting partner
	{
		err = acceptSocket-&gt;GetLastError();
        return NET_ACCEPTERROR; 
	}
    if (*refreshSocket == NULL) 
    {
        return NET_NOTCONNECTED;
    }
...
</code></pre>
<p>Kennt jemand das Problem und kann mir helfen?</p>
<p>Gruß,<br />
-r</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/161896/dll-problem-mit-csocket</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Jul 2026 13:44:03 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/161896.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 12 Oct 2006 09:16:35 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to DLL-Problem mit CSocket on Thu, 12 Oct 2006 09:16:35 GMT]]></title><description><![CDATA[<p>Nachdem ich nun stundenlang gegoogled habe, denke ich mein Problem soweit erkannt zu haben...</p>
<p>Ich habe ein Programm geschrieben, das Daten von einem Server über einen Socket erhält. Wir gehen eine Verbindung zum Server ein, loggen uns ein und erhalten Daten...<br />
Als .exe funktioniert es zumindest. Umgewandelt als dll scheitert es allerdings.</p>
<p>Das empfangen der Daten soll in einem Thread passieren (was vermutlich das Problem ist!)</p>
<pre><code class="language-cpp">UINT CRTclient::MyThreadProc(LPVOID pParam)
{
    CSocket *refreshSocket = new CSocket();
    CAsyncSocket *acceptSocket;
    int reply;
    char *inByte = 0;
    char **lines;
    int *lineCount;
    int err = 0;	
	CString sockAddress;
	UINT portAddress;

	lineCount = (int*)malloc(sizeof(int));
    acceptSocket = new(CAsyncSocket);

	if (!AfxSocketInit())
	{
		AfxMessageBox(&quot;IDP_SOCKETS_INIT_FAILED&quot;);
		return FALSE;
	}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//************************************************************************************************************//
// Die scheiternde Zeile:
    if (!acceptSocket-&gt;Create(9058)) // we let windows find a good port 9058
    {
        err = acceptSocket-&gt;GetLastError(); //just for debugging
        return NET_CREATEERROR; 
    }
    // we get the assigned port address
    if (0 == acceptSocket-&gt;GetSockName(sockAddress, portAddress))
    {
        err = acceptSocket-&gt;GetLastError(); //just for debugging
        return NET_GETPORTERROR; 
    }
    refreshPort = (int)portAddress;  //we communicate the port address to the main thread ...
	refreshPort = 25123;
	err = acceptSocket-&gt;Listen(5);
    if (0 == err) // no waiting partner
	{
		err = acceptSocket-&gt;GetLastError();
        return NET_ACCEPTERROR; 
	}
    if (!acceptSocket-&gt;Accept(*refreshSocket)) // no waiting partner
	{
		err = acceptSocket-&gt;GetLastError();
        return NET_ACCEPTERROR; 
	}
    if (*refreshSocket == NULL) 
    {
        return NET_NOTCONNECTED;
    }
...
</code></pre>
<p>Kennt jemand das Problem und kann mir helfen?</p>
<p>Gruß,<br />
-r</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1153294</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1153294</guid><dc:creator><![CDATA[raterchen]]></dc:creator><pubDate>Thu, 12 Oct 2006 09:16:35 GMT</pubDate></item></channel></rss>