<?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[Probleme mit Named Pipes]]></title><description><![CDATA[<p>Hallo allerseitz...</p>
<p>Ich hoffe Ihr könnt mir Helfen.</p>
<p>Erstmal was mein Problem ist:<br />
Ich habe einen Thread, in dem ich eine Verbindung mit einem IRC Server herstelle.<br />
Nun will ich, aus jedem anderen belibigen Thread über diese internet verbindung was verschicken (Test-Nachrichten)<br />
Dafür habe ich eine Named Pipe erstell:</p>
<pre><code class="language-cpp">DWORD WINAPI irc(PARAMS* par) {
    char pbuffer[260] = &quot;&quot;;
    DWORD dwRead;
    HANDLE pipe = CreateNamedPipe(&quot;\\\\.\\pipe\\qbic&quot;, PIPE_ACCESS_INBOUND, PIPE_NOWAIT, PIPE_UNLIMITED_INSTANCES, 256, 256, 120*1000, NULL);
    ConnectNamedPipe(pipe, NULL);
    while(1) {
        memset(pbuffer, 0, 260);
        ReadFile(pipe, pbuffer, 256, &amp;dwRead, NULL);
        if(strcmp(pbuffer, &quot;&quot;)) {
            IRCMessage(pbuffer);
        }
        }
        Sleep(1);
    }
</code></pre>
<p>So in der volgenden Funktion sende ich entwas an die Pipe:</p>
<pre><code class="language-cpp">void toirc(char * msg, ...) {
    HANDLE pipe = CreateFile(&quot;\\\\.\\pipe\\qbic&quot;, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
    char buffer[256] = &quot;&quot;;
    DWORD dwSent;

    va_list args;
    va_start(args, msg);
    vsprintf(buffer,msg, args);

    WriteFile(pipe,buffer,sizeof(buffer)+1,&amp;dwSent,NULL);

    va_end(args);

    CloseHandle(pipe);
}
</code></pre>
<p>Das funzt beim ersten mal auch ganz gut, aber beim 2. mal ausführen, gibt es volgende Errors:<br />
CreateFile() returned error code: 231<br />
WriteFile() returned error code: 6<br />
(Per GetLastError() rausbekommen...)</p>
<p>Jetzt meine Frage, wie kann ich auch öfter was über diese Pipe schicken?<br />
Oder gibt es evtl. einen besseren lösungsweg für mein Vorhaben?</p>
<p>MfG</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/236944/probleme-mit-named-pipes</link><generator>RSS for Node</generator><lastBuildDate>Tue, 07 Apr 2026 17:08:57 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/236944.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 22 Mar 2009 10:17:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Probleme mit Named Pipes on Sun, 22 Mar 2009 10:17:52 GMT]]></title><description><![CDATA[<p>Hallo allerseitz...</p>
<p>Ich hoffe Ihr könnt mir Helfen.</p>
<p>Erstmal was mein Problem ist:<br />
Ich habe einen Thread, in dem ich eine Verbindung mit einem IRC Server herstelle.<br />
Nun will ich, aus jedem anderen belibigen Thread über diese internet verbindung was verschicken (Test-Nachrichten)<br />
Dafür habe ich eine Named Pipe erstell:</p>
<pre><code class="language-cpp">DWORD WINAPI irc(PARAMS* par) {
    char pbuffer[260] = &quot;&quot;;
    DWORD dwRead;
    HANDLE pipe = CreateNamedPipe(&quot;\\\\.\\pipe\\qbic&quot;, PIPE_ACCESS_INBOUND, PIPE_NOWAIT, PIPE_UNLIMITED_INSTANCES, 256, 256, 120*1000, NULL);
    ConnectNamedPipe(pipe, NULL);
    while(1) {
        memset(pbuffer, 0, 260);
        ReadFile(pipe, pbuffer, 256, &amp;dwRead, NULL);
        if(strcmp(pbuffer, &quot;&quot;)) {
            IRCMessage(pbuffer);
        }
        }
        Sleep(1);
    }
</code></pre>
<p>So in der volgenden Funktion sende ich entwas an die Pipe:</p>
<pre><code class="language-cpp">void toirc(char * msg, ...) {
    HANDLE pipe = CreateFile(&quot;\\\\.\\pipe\\qbic&quot;, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
    char buffer[256] = &quot;&quot;;
    DWORD dwSent;

    va_list args;
    va_start(args, msg);
    vsprintf(buffer,msg, args);

    WriteFile(pipe,buffer,sizeof(buffer)+1,&amp;dwSent,NULL);

    va_end(args);

    CloseHandle(pipe);
}
</code></pre>
<p>Das funzt beim ersten mal auch ganz gut, aber beim 2. mal ausführen, gibt es volgende Errors:<br />
CreateFile() returned error code: 231<br />
WriteFile() returned error code: 6<br />
(Per GetLastError() rausbekommen...)</p>
<p>Jetzt meine Frage, wie kann ich auch öfter was über diese Pipe schicken?<br />
Oder gibt es evtl. einen besseren lösungsweg für mein Vorhaben?</p>
<p>MfG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1684165</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1684165</guid><dc:creator><![CDATA[_.-noel-._]]></dc:creator><pubDate>Sun, 22 Mar 2009 10:17:52 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit Named Pipes on Sun, 22 Mar 2009 11:28:28 GMT]]></title><description><![CDATA[<p>CreateNamedPipe und ReadFile reicht nicht.</p>
<p>Server:</p>
<pre><code>CreateNamedPipe
while (1)
{
	ConnectNamedPipe
	ReadFile
	DisconnectNamedPipe
}
</code></pre>
<p>Client:</p>
<pre><code>try:
CreateFile
if error==ERROR_PIPE_BUSY
	WaitNamedPipe(name, time)
	goto try
else if error
	no_server()
	// queue.Add(message)
else
	// queue.SendAll()
	WriteFile/TransactNamedPipe
	CloseHandle
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1684190</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1684190</guid><dc:creator><![CDATA[sapero]]></dc:creator><pubDate>Sun, 22 Mar 2009 11:28:28 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit Named Pipes on Sun, 22 Mar 2009 17:10:48 GMT]]></title><description><![CDATA[<p>Ok danke, hat mir ein Stück weitergeholfen, aber jetzt hab ich wieder ein Problem.</p>
<p>Und zwar hab ich hier die Function zum senden, die warten soll, falls die pipe nochnicht existiert.</p>
<pre><code class="language-cpp">void toirc(char * msg, ...) {
    HANDLE pipe;
    WaitNamedPipe(&quot;\\\\.\\pipe\\qbic&quot;, NMPWAIT_WAIT_FOREVER);
    do {
        pipe = CreateFile(&quot;\\\\.\\pipe\\qbic&quot;, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
    } while (pipe == INVALID_HANDLE_VALUE);
    cout &lt;&lt; endl &lt;&lt; &quot;CreateFile: &quot; &lt;&lt; GetLastError() &lt;&lt; endl;
    char buffer[256] = &quot;&quot;;
    DWORD dwSent;

    va_list args;
    va_start(args, msg);
    vsprintf(buffer,msg, args);

    WriteFile(pipe,buffer,sizeof(buffer)+1,&amp;dwSent,NULL);
    cout &lt;&lt; endl &lt;&lt; &quot;WriteFile: &quot; &lt;&lt; GetLastError() &lt;&lt; endl;

    va_end(args);

    CloseHandle(pipe);
}
</code></pre>
<p>Das Problem ist jetzt, sobald ich öfters diese function aufrufen, scheint es bei WriteFile(pipe,buffer,sizeof(buffer)+1,&amp;dwSent,NULL); einfach zu stoppen.</p>
<p>ich hab vor WriteFile und danach eine ausgabe machen lassen, es kahm nur die davor an, also denke ich es liegt an dem WriteFile ...</p>
<p>Habe ich was falsch gemacht?</p>
<p>MfG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1684379</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1684379</guid><dc:creator><![CDATA[_.-noel-._]]></dc:creator><pubDate>Sun, 22 Mar 2009 17:10:48 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit Named Pipes on Sun, 22 Mar 2009 18:23:55 GMT]]></title><description><![CDATA[<p>Sry für Doppelpost, nur edit geht leider nicht...</p>
<p>Ich hab jetzt herrausgefunden, das das senden bei genau 2 funktionen nicht funzt...<br />
eine funktion zum plugin starten, die andere zum stoppen...<br />
ich hab noch eine funktion, die check ob alle plugins laufen wie sie sollen, diese funktion wird jede sekunde in einer while ausgeführ...die funktion liegt in der gleichen klasse, und da funktionierts tadenlos...</p>
<p>Ich weis ehrlich nicht was ich da jetzt machen soll ?!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1684409</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1684409</guid><dc:creator><![CDATA[_.-noel-._]]></dc:creator><pubDate>Sun, 22 Mar 2009 18:23:55 GMT</pubDate></item></channel></rss>