<?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[[WinSock] Dateien versenden]]></title><description><![CDATA[<p>Jaja ich weiß. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /><br />
Mein Problem ist nur, dass egal mit welcher Variante immer ein Problem besteht...<br />
Wenn ich zum Beispiel via fopen () eine .exe-Datei öffne und segmentweise verschicke, kommt sie zwar an, allerdings fehlt schon das Icon der .exe und wenn ich sie starte, sagt er, dass er ein Problem festgestellt hat und das Programm beendet werden musste. Das geht auch mit anderen Dateitypen so, die kommen eben manchmal (ja, manchmal klappts auch) nur stückweise an und ich habe keine Ahnung woran das liegt...</p>
<p>so empfange ich die Dateien:</p>
<pre><code class="language-cpp">...

pFile = fopen (buffer, &quot;wb&quot;);
if (pFile == 0)
{
    fclose (pFile);
    OutputDebugString (&quot;(ERROR) WAXSOCKET::RecvData () -&gt; fopen () fehlgeschlagen!\n&quot;);
    return WSERROR_FILE;
}

iData = wsh.iFileSize;

char file[4096];

while (iData &gt; 0)
{
    dwData = recv (sSocket, file, 4096, 0);
    fwrite (file, dwData, 1, pFile);

    iData -= dwData;
}

fclose (pFile);

...
</code></pre>
<p>und so sende ich sie:</p>
<pre><code class="language-cpp">...

//TEIL 1: öffnen und analysieren der Datei
pFile = fopen (tyData, &quot;rb&quot;);
if (pFile == 0)
{
    fclose (pFile);
    OutputDebugString (&quot;(ERROR) WAXSOCKET::RecvData () -&gt; fopen () fehlgeschlagen!\n&quot;);
    return WSERROR_FILE;
}

fseek (pFile, 0, SEEK_END);
iData = ftell (pFile);
fseek (pFile, 0, SEEK_SET);

wsh.iFileSize = iData;

lstrcpy (wsh.lpFile, ::FormatFileString ((char*) tyData));
wsh.iSendMode = SEND_FILE;
wsh.iBlockSize = SEND_BLOCKSIZE;

...

//TEIL 2: senden der Datei
char file[4096];

while (iData &gt;= 4096)
{
    fread (file, 4096, 1, pFile);
    send (sSocket, file, 4096, 0);

    iData -= 4096;
}

if (iData != 0)
{
    fread (file, iData, 0, pFile);
    send (sSocket, file, iData, 0);
}

fclose (pFile);

...
</code></pre>
<p>Das ganze ist Teil einer Klasse, die aber eigentlich keine weitere große Bedeutung hat. Falls doch noch Unklarheiten bestehen, einfach fragen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /><br />
Danke schonmal im voraus!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/203257/winsock-dateien-versenden</link><generator>RSS for Node</generator><lastBuildDate>Mon, 27 Apr 2026 06:29:10 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/203257.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 20 Jan 2008 22:52:55 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [WinSock] Dateien versenden on Sun, 20 Jan 2008 22:52:55 GMT]]></title><description><![CDATA[<p>Jaja ich weiß. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /><br />
Mein Problem ist nur, dass egal mit welcher Variante immer ein Problem besteht...<br />
Wenn ich zum Beispiel via fopen () eine .exe-Datei öffne und segmentweise verschicke, kommt sie zwar an, allerdings fehlt schon das Icon der .exe und wenn ich sie starte, sagt er, dass er ein Problem festgestellt hat und das Programm beendet werden musste. Das geht auch mit anderen Dateitypen so, die kommen eben manchmal (ja, manchmal klappts auch) nur stückweise an und ich habe keine Ahnung woran das liegt...</p>
<p>so empfange ich die Dateien:</p>
<pre><code class="language-cpp">...

pFile = fopen (buffer, &quot;wb&quot;);
if (pFile == 0)
{
    fclose (pFile);
    OutputDebugString (&quot;(ERROR) WAXSOCKET::RecvData () -&gt; fopen () fehlgeschlagen!\n&quot;);
    return WSERROR_FILE;
}

iData = wsh.iFileSize;

char file[4096];

while (iData &gt; 0)
{
    dwData = recv (sSocket, file, 4096, 0);
    fwrite (file, dwData, 1, pFile);

    iData -= dwData;
}

fclose (pFile);

...
</code></pre>
<p>und so sende ich sie:</p>
<pre><code class="language-cpp">...

//TEIL 1: öffnen und analysieren der Datei
pFile = fopen (tyData, &quot;rb&quot;);
if (pFile == 0)
{
    fclose (pFile);
    OutputDebugString (&quot;(ERROR) WAXSOCKET::RecvData () -&gt; fopen () fehlgeschlagen!\n&quot;);
    return WSERROR_FILE;
}

fseek (pFile, 0, SEEK_END);
iData = ftell (pFile);
fseek (pFile, 0, SEEK_SET);

wsh.iFileSize = iData;

lstrcpy (wsh.lpFile, ::FormatFileString ((char*) tyData));
wsh.iSendMode = SEND_FILE;
wsh.iBlockSize = SEND_BLOCKSIZE;

...

//TEIL 2: senden der Datei
char file[4096];

while (iData &gt;= 4096)
{
    fread (file, 4096, 1, pFile);
    send (sSocket, file, 4096, 0);

    iData -= 4096;
}

if (iData != 0)
{
    fread (file, iData, 0, pFile);
    send (sSocket, file, iData, 0);
}

fclose (pFile);

...
</code></pre>
<p>Das ganze ist Teil einer Klasse, die aber eigentlich keine weitere große Bedeutung hat. Falls doch noch Unklarheiten bestehen, einfach fragen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /><br />
Danke schonmal im voraus!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1440238</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1440238</guid><dc:creator><![CDATA[Fake oder Echt]]></dc:creator><pubDate>Sun, 20 Jan 2008 22:52:55 GMT</pubDate></item><item><title><![CDATA[Reply to [WinSock] Dateien versenden on Mon, 21 Jan 2008 09:06:47 GMT]]></title><description><![CDATA[<p>Für was benötigst Du lstrcpy?<br />
Die Funktion arbeitet mit NULL- terminierten Strings, Du aber mit binary Daten...</p>
<p>Simon</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1440365</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1440365</guid><dc:creator><![CDATA[simon.gysi]]></dc:creator><pubDate>Mon, 21 Jan 2008 09:06:47 GMT</pubDate></item><item><title><![CDATA[Reply to [WinSock] Dateien versenden on Mon, 21 Jan 2008 11:23:18 GMT]]></title><description><![CDATA[<p>lstrcpy benötige ich, um wsh.lpFile mit dem Dateinamen zu füllen. FormatFilString () macht nichts anderes, als den Dateinamen aus einer Pfadangabe zu extrahieren...<br />
Ich habe nur eine Sende-Funktion, die je nach Angabe entweder einen einfachen String, eine Struktur oder eben eine Datei versendet. Damit der Empfänger aber weiß, was gemacht wird, schicke ich vorher einen Header los der alle nötigen Informationen enthält...</p>
<p>Meinst du, dass send () mit NULL terminierten Strings arbeitet, oder lstrcpy () ??</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1440490</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1440490</guid><dc:creator><![CDATA[Fake oder Echt]]></dc:creator><pubDate>Mon, 21 Jan 2008 11:23:18 GMT</pubDate></item><item><title><![CDATA[Reply to [WinSock] Dateien versenden on Tue, 22 Jan 2008 10:44:18 GMT]]></title><description><![CDATA[<p>also erstmal: *push* <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /><br />
und dann: hat vllt. jmd noche in andere lösung die aber auch komplett funktioniert?? weil diese klasse ist verdammt wichtig für mich <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1441161</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1441161</guid><dc:creator><![CDATA[Fake oder Echt]]></dc:creator><pubDate>Tue, 22 Jan 2008 10:44:18 GMT</pubDate></item></channel></rss>