<?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 datei sende problem]]></title><description><![CDATA[<p>Ich hab ein Problem beim senden.Hier der quelltext:<br />
Server:</p>
<pre><code class="language-cpp">int Filesize;
rc = recv(cs,buf,11,0);
if(buf[0]=='2' &amp;&amp; buf[1]=='.' &amp;&amp;  buf[2]=='3' || buf[2]=='4')
{

		buf[0]='0';

			rc = send(cs,buf,10,0);
			return 0;
}
else
{
buf[0]=1;
rc = send(cs,buf,3,0);

rc = recv(cs,buf,11,0);
if(buf[0]=1)
{
	Filesize=sizeof(update);
	 buf[0]=Filesize;

	rc = send(cs,buf,200,0);
	char buf2[sizeof(update)];
	update.get(buf2,sizeof(update));
	rc = recv(cs,buf,200,0);
	cout&lt;&lt;buf&lt;&lt;&quot;\n\n&quot;;

	cin.get();
	Sleep(2000);
	while(Filesize&gt;0)
	{
		rc = send(cs,buf2,sizeof(update),0);
	Filesize=Filesize-1;
	}
	update.close();

}
else
{
}
</code></pre>
<p>Client:</p>
<pre><code class="language-cpp">//darüber version überprüfung
else if (test[0]='1')
{
	buf[0]='1';
		rc = send(s,buf,10,0);

		rc = recv(s,buf,3,0);

	Filesize=(int) buf;

char *buf2;
buf2=new char(100000);

cout&lt;&lt;&quot;Warte auf daten!\n\n&quot;;
 rc = send(s,buf2,20,0);

 int fz=Filesize;
 cout&lt;&lt;&quot;Zu übertragende Bytes: &quot;&lt;&lt;fz&lt;&lt;&quot;\n&quot;;

while(deux&gt;0)
{
    cout&lt;&lt;&quot;\rÜbertragen: &quot;&lt;&lt;Filesize;
	rc = recv( s, buf2, fz, 0 );

Filesize=Filesize-1;
}
update &lt;&lt; buf2;
cout&lt;&lt;&quot;\n\nFertig\n&quot;;
cin.get();

delete buf2;
update.close();
}
</code></pre>
<p>Ich will ein Textfile kopieren.Zuerst lese ich mit dem Server<br />
die grösse aus sende diese dem Client.<br />
danach wird beim senden die grösse immer um eins verringert.<br />
Eigentlich steht in der Datei nur ein &quot;hallo wie gehts?&quot;.<br />
Irgend wie sendet der Server nicht und irgendwie empfängt<br />
der client was aber irgendwie nicht weil im Textfile vom<br />
Client nichts steht.Das schließe ich daraus das er Filesize rechnet<br />
obwohl der server nichts tut.Weil eigentlich<br />
hält das programm bei send oder recv bis es ausgeführt wurde an.<br />
Beim Clienten ist es nicht so.Un beim Server stimmt<br />
es irgendwie auch nicht.Ich sende ja die File größe an den Clienten der<br />
hat dann die zahl 2292240(halt die grösse).Beim server aber ist sie<br />
nur *mal* 510 oder 540 usw groß es ändert sich immer.<br />
Und wenn der Client runter gezählt hat und aus ist da<br />
hat er plötzlich gerechnet und hat am ende 100.<br />
Was mach ich falsch?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/124718/winsock-datei-sende-problem</link><generator>RSS for Node</generator><lastBuildDate>Tue, 07 Jul 2026 13:40:14 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/124718.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 30 Oct 2005 20:00:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Winsock datei sende problem on Sun, 30 Oct 2005 20:00:02 GMT]]></title><description><![CDATA[<p>Ich hab ein Problem beim senden.Hier der quelltext:<br />
Server:</p>
<pre><code class="language-cpp">int Filesize;
rc = recv(cs,buf,11,0);
if(buf[0]=='2' &amp;&amp; buf[1]=='.' &amp;&amp;  buf[2]=='3' || buf[2]=='4')
{

		buf[0]='0';

			rc = send(cs,buf,10,0);
			return 0;
}
else
{
buf[0]=1;
rc = send(cs,buf,3,0);

rc = recv(cs,buf,11,0);
if(buf[0]=1)
{
	Filesize=sizeof(update);
	 buf[0]=Filesize;

	rc = send(cs,buf,200,0);
	char buf2[sizeof(update)];
	update.get(buf2,sizeof(update));
	rc = recv(cs,buf,200,0);
	cout&lt;&lt;buf&lt;&lt;&quot;\n\n&quot;;

	cin.get();
	Sleep(2000);
	while(Filesize&gt;0)
	{
		rc = send(cs,buf2,sizeof(update),0);
	Filesize=Filesize-1;
	}
	update.close();

}
else
{
}
</code></pre>
<p>Client:</p>
<pre><code class="language-cpp">//darüber version überprüfung
else if (test[0]='1')
{
	buf[0]='1';
		rc = send(s,buf,10,0);

		rc = recv(s,buf,3,0);

	Filesize=(int) buf;

char *buf2;
buf2=new char(100000);

cout&lt;&lt;&quot;Warte auf daten!\n\n&quot;;
 rc = send(s,buf2,20,0);

 int fz=Filesize;
 cout&lt;&lt;&quot;Zu übertragende Bytes: &quot;&lt;&lt;fz&lt;&lt;&quot;\n&quot;;

while(deux&gt;0)
{
    cout&lt;&lt;&quot;\rÜbertragen: &quot;&lt;&lt;Filesize;
	rc = recv( s, buf2, fz, 0 );

Filesize=Filesize-1;
}
update &lt;&lt; buf2;
cout&lt;&lt;&quot;\n\nFertig\n&quot;;
cin.get();

delete buf2;
update.close();
}
</code></pre>
<p>Ich will ein Textfile kopieren.Zuerst lese ich mit dem Server<br />
die grösse aus sende diese dem Client.<br />
danach wird beim senden die grösse immer um eins verringert.<br />
Eigentlich steht in der Datei nur ein &quot;hallo wie gehts?&quot;.<br />
Irgend wie sendet der Server nicht und irgendwie empfängt<br />
der client was aber irgendwie nicht weil im Textfile vom<br />
Client nichts steht.Das schließe ich daraus das er Filesize rechnet<br />
obwohl der server nichts tut.Weil eigentlich<br />
hält das programm bei send oder recv bis es ausgeführt wurde an.<br />
Beim Clienten ist es nicht so.Un beim Server stimmt<br />
es irgendwie auch nicht.Ich sende ja die File größe an den Clienten der<br />
hat dann die zahl 2292240(halt die grösse).Beim server aber ist sie<br />
nur *mal* 510 oder 540 usw groß es ändert sich immer.<br />
Und wenn der Client runter gezählt hat und aus ist da<br />
hat er plötzlich gerechnet und hat am ende 100.<br />
Was mach ich falsch?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/904080</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/904080</guid><dc:creator><![CDATA[Stefan311]]></dc:creator><pubDate>Sun, 30 Oct 2005 20:00:02 GMT</pubDate></item><item><title><![CDATA[Reply to Winsock datei sende problem on Sun, 30 Oct 2005 20:22:54 GMT]]></title><description><![CDATA[<p>Du überprüfst ja gar nicht wieviel du wirklich empfangen hast nach dem Aufruf von recv?!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/904098</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/904098</guid><dc:creator><![CDATA[:confused:]]></dc:creator><pubDate>Sun, 30 Oct 2005 20:22:54 GMT</pubDate></item><item><title><![CDATA[Reply to Winsock datei sende problem on Sun, 30 Oct 2005 20:33:34 GMT]]></title><description><![CDATA[<p>Meinen sie das könnte damit zusammen hängen?Und wie geht das?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/904117</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/904117</guid><dc:creator><![CDATA[Stefan311]]></dc:creator><pubDate>Sun, 30 Oct 2005 20:33:34 GMT</pubDate></item><item><title><![CDATA[Reply to Winsock datei sende problem on Sun, 30 Oct 2005 20:46:41 GMT]]></title><description><![CDATA[<p>ich kann ihnen nur empfehlen alles nochmal neu zu schreiben. der code ist momentan grauenhaft.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/904125</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/904125</guid><dc:creator><![CDATA[tipp]]></dc:creator><pubDate>Sun, 30 Oct 2005 20:46:41 GMT</pubDate></item><item><title><![CDATA[Reply to Winsock datei sende problem on Mon, 31 Oct 2005 13:43:43 GMT]]></title><description><![CDATA[<p>Ok ich hab ihn noch nicht auskommentiert. Mach ich aber noch.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/904529</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/904529</guid><dc:creator><![CDATA[Stefan311]]></dc:creator><pubDate>Mon, 31 Oct 2005 13:43:43 GMT</pubDate></item><item><title><![CDATA[Reply to Winsock datei sende problem on Mon, 31 Oct 2005 17:03:59 GMT]]></title><description><![CDATA[<p>Ich poste in solchen fällen immer wieder gerne folgendes:<br />
<a href="http://aluigi.altervista.org/mytoolz/sendrecv.zip" rel="nofollow">http://aluigi.altervista.org/mytoolz/sendrecv.zip</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/904790</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/904790</guid><dc:creator><![CDATA[-*NULL*-]]></dc:creator><pubDate>Mon, 31 Oct 2005 17:03:59 GMT</pubDate></item><item><title><![CDATA[Reply to Winsock datei sende problem on Mon, 31 Oct 2005 17:50:51 GMT]]></title><description><![CDATA[<p>achtet mal auf den ordnernamen - mytool<strong>z</strong> - hört sich gefährlich an <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/26a0.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--warning"
      title=":warning:"
      alt="⚠"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/26a0.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--warning"
      title=":warning:"
      alt="⚠"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/904864</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/904864</guid><dc:creator><![CDATA[:warning:]]></dc:creator><pubDate>Mon, 31 Oct 2005 17:50:51 GMT</pubDate></item><item><title><![CDATA[Reply to Winsock datei sende problem on Mon, 31 Oct 2005 18:53:58 GMT]]></title><description><![CDATA[<p>Ich kann es nicht öffnen Winrar sagt es sei beschädigt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/904929</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/904929</guid><dc:creator><![CDATA[Stefan311]]></dc:creator><pubDate>Mon, 31 Oct 2005 18:53:58 GMT</pubDate></item><item><title><![CDATA[Reply to Winsock datei sende problem on Mon, 31 Oct 2005 18:57:10 GMT]]></title><description><![CDATA[<p>kopier mal den link und füg ihn in eine neues browser fenster ein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/904932</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/904932</guid><dc:creator><![CDATA[.............]]></dc:creator><pubDate>Mon, 31 Oct 2005 18:57:10 GMT</pubDate></item><item><title><![CDATA[Reply to Winsock datei sende problem on Mon, 31 Oct 2005 19:04:55 GMT]]></title><description><![CDATA[<p>Problem gelöst.Ich schau's mir dann mal an. Danke so wie dein Programm soll das am ende aussehen. Bei mir hatte ich unter anderen das Problem mit der Dateigröße<br />
rausfinden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/904936</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/904936</guid><dc:creator><![CDATA[Stefan311]]></dc:creator><pubDate>Mon, 31 Oct 2005 19:04:55 GMT</pubDate></item><item><title><![CDATA[Reply to Winsock datei sende problem on Tue, 01 Nov 2005 19:22:25 GMT]]></title><description><![CDATA[<p>So eine Frage neben bei weil ich ja das ganz selber machen will also nichst<br />
von irgendjemand rauskopieren schauen was passiert...Jetzt meine Frage ich<br />
lesen mit GetFileSize die größe aus in ein DWORD.Datei=10.8 MB groß reicht<br />
DWORD?Und wenn ja Wie kriege ich diese werte in ein char um diese<br />
per send zu senden und in einen intiger um mein char die richtige größe<br />
reservieren kann.<br />
Und das hier weiß hab ich leider vergessen:</p>
<pre><code class="language-cpp">char *buf2;
buf2=new char(1024);//ist das in den() bit,byte..?
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/905949</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/905949</guid><dc:creator><![CDATA[Stefan311]]></dc:creator><pubDate>Tue, 01 Nov 2005 19:22:25 GMT</pubDate></item><item><title><![CDATA[Reply to Winsock datei sende problem on Tue, 01 Nov 2005 22:07:36 GMT]]></title><description><![CDATA[<p>ja.<br />
und<br />
byte.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/906047</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/906047</guid><dc:creator><![CDATA[short_one]]></dc:creator><pubDate>Tue, 01 Nov 2005 22:07:36 GMT</pubDate></item><item><title><![CDATA[Reply to Winsock datei sende problem on Wed, 02 Nov 2005 10:23:33 GMT]]></title><description><![CDATA[<p>Du dürftest aber eckige Klammern benötigen - so belegst du nur Platz für ein char (mit dem Wert 1024 =&gt; 0).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/906282</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/906282</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 02 Nov 2005 10:23:33 GMT</pubDate></item><item><title><![CDATA[Reply to Winsock datei sende problem on Wed, 02 Nov 2005 12:41:18 GMT]]></title><description><![CDATA[<p>Stefan311 schrieb:</p>
<blockquote>
<p>So eine Frage neben bei weil ich ja das ganz selber machen will also nichst<br />
von irgendjemand rauskopieren schauen was passiert...Jetzt meine Frage ich<br />
lesen mit GetFileSize die größe aus in ein DWORD.Datei=10.8 MB groß reicht<br />
DWORD?Und wenn ja Wie kriege ich diese werte in ein char um diese<br />
per send zu senden und in einen intiger um mein char die richtige größe<br />
reservieren kann.<br />
Und das hier weiß hab ich leider vergessen:</p>
<pre><code class="language-cpp">char *buf2;
buf2=new char(1024);//ist das in den() bit,byte..?
</code></pre>
</blockquote>
<pre><code class="language-cpp">char  cBufToSend[1024];
HANDLE hFile;
DWORD dwFileSize;

hFile = GreateFile( bla, bla bla, sorry bin zu faul);

dwFileSize = GetFileSize(hFile, 0);

_snprintf(cBufToSend, sizeof(cBufToSend), &quot;%d&quot;, dwFileSize);

send( sock, cBufToSend, lstrlen(cBufToSend), 0);
</code></pre>
<p>Server empfängt String und prepariert es:</p>
<pre><code class="language-cpp">DWORD dwFileSize;
recv( sock, cBufToRecv, sizeof(cBufToRecv), 0);

dwFileSize = atof(cBufToRecv);
</code></pre>
<p>so hätte ich es gemacht,</p>
<p>danach kannst du die Datei Byteweise in cBufToSend einlesen mod:&quot;rb&quot; (bis EOF erkannt wird) und per Socket versenden.<br />
Der Server empfängt dann den Buffer und schreibt es in vorher mit CreateFile erstellte Datei rein.</p>
<p>Also du muss ein Protokol entwickeln:<br />
z.B.</p>
<p>char buf[1024];<br />
dann sieht der Transfer so aus<br />
-&gt;[ part1$$<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>F</mi><mi>i</mi><mi>l</mi><mi>e</mi><mi>S</mi><mi>i</mi><mi>z</mi><mi>e</mi></mrow><annotation encoding="application/x-tex">FileSize</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.69444em;"></span><span class="strut bottom" style="height:0.69444em;vertical-align:0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right:0.13889em;">F</span><span class="mord mathit">i</span><span class="mord mathit" style="margin-right:0.01968em;">l</span><span class="mord mathit">e</span><span class="mord mathit" style="margin-right:0.05764em;">S</span><span class="mord mathit">i</span><span class="mord mathit" style="margin-right:0.04398em;">z</span><span class="mord mathit">e</span></span></span></span>$$FileName.exe$$00000000 binäre data 0000000000000\]  
->\[ part2$$000000000000000000 binäre data 00000000000000000000000000000]<br />
...<br />
-&gt;[ partX$$000000000000000000 binäre data 0000000000000000$$EndOfFile]</p>
<p>wobei $$$ ein Trenner ist.</p>
<p>Dein Empfänger muss dann solange die Daten empfangen und in Datei schreiben bis er im String EndOfFile findet. Hoffe du verstehst mich, mein Deutsch ist noch zimlich schlecht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>Stefan311 schrieb:</p>
<blockquote>
<p>char *buf2;<br />
buf2=new char(1024);//ist das in den() bit,byte..?</p>
</blockquote>
<p>Na was denkst du was das &quot;char&quot; wohl ist??? Bit??? Byte??? oder DWORD???<br />
Dein Pointer(buf2) zeigt nun auf ein 1024 BYTES große Bereich im Speicher <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/906392</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/906392</guid><dc:creator><![CDATA[Ausländer]]></dc:creator><pubDate>Wed, 02 Nov 2005 12:41:18 GMT</pubDate></item><item><title><![CDATA[Reply to Winsock datei sende problem on Wed, 02 Nov 2005 14:11:56 GMT]]></title><description><![CDATA[<p>Danke für die vielen antworten.Endlich weiß ich wieder was<br />
das in der klammer war.Jetzt muss ich erstmal viel nachdenken wie ich<br />
das am besten mache und muss mich mal noch ein wenig unter msdn<br />
über Createfile schlau machen.Ich hab schomal(für was anderes) versuch mit<br />
Createfile etwas zu erstellen.Da war ich überfordert mit DWORD usw..Inszwischen<br />
hab ich es verstanden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/906469</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/906469</guid><dc:creator><![CDATA[Stefan311]]></dc:creator><pubDate>Wed, 02 Nov 2005 14:11:56 GMT</pubDate></item><item><title><![CDATA[Reply to Winsock datei sende problem on Wed, 02 Nov 2005 19:05:37 GMT]]></title><description><![CDATA[<p>Jetzt hab ich mal wieder ne Frage GetFileSize gibt ja bytes zurück.<br />
Aber sind 10,8 MB = 4294967295 Bytes sind? Und wenn ja<br />
warum dauert das senden so lange?</p>
<p>im moment hab ich das so:</p>
<pre><code class="language-cpp">while(FileSize&gt;0)
{
cout&lt;&lt;&quot;\rÜbertragen: &quot;&lt;&lt;FileSize;
rc = send();
FileSize=FileSize - rc;
}
</code></pre>
<p>Ist das so richtig?<br />
Ps:Hab gerade festgestellt das die datei die der Client speichert größer ist<br />
als die Ausgangsdatei. Was ist falsch?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/906730</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/906730</guid><dc:creator><![CDATA[Stefan311]]></dc:creator><pubDate>Wed, 02 Nov 2005 19:05:37 GMT</pubDate></item><item><title><![CDATA[Reply to Winsock datei sende problem on Wed, 02 Nov 2005 21:03:21 GMT]]></title><description><![CDATA[<p>Also Stefan ich verstehe das du alles selber machen willst, aber irgendwie ist<br />
mir einfacher dir ein Beispiel zu zeigen als das ganze zu erklären. Und ein Beispiel, meiner Meinung nach sagt/zeigt es besser als ich.</p>
<p>Also ich stünde auch vor langer Zeit vor dem Problem ein Datei über Winsock zu versenden und ich habe es so gemacht:</p>
<p>Beachte dass das ein einfacher Beispiel ist und evtl. noch verbessert werden kann</p>
<pre><code class="language-cpp">//Sender (Client) Diese Teil versendet ein Datei
#include &lt;stdio.h&gt;
#include &lt;winsock2.h&gt;

int startWinsock(void)
{
	WSADATA wsa;
	return WSAStartup(MAKEWORD(2,0),&amp;wsa);
}

int main(void)
{
	SOCKET s;
	SOCKADDR_IN addr;
	FILE *file;
	char buf[1024];
	int num;

	char ip[]    = &quot;127.0.0.1&quot;;	// Ziel-IP
	int port     = 123;		// Port
	char datei[] = &quot;C:\\file.exe&quot;;// Datei zum versenden

	printf(&quot;\n&quot;);

//-----------------------------------------------------------
	// Winsock initialisieren 	 
	if( startWinsock() != 0 )
	{
		printf(&quot;Fehler: Winsock kann nicht initialisiert werden\n\n&quot;);
		return 1; 
	}

//-----------------------------------------------------------------
	// Socket erstellen 
	s = socket(AF_INET,SOCK_STREAM,0);
	if( s == INVALID_SOCKET )
	{
		printf(&quot;Fehler: Socket kann nicht erstellt werden\n\n&quot;);
		return 1; 
	}

//-----------------------------------------------------------
	// Verbinden mit Zielhost 
	memset(&amp;addr, 0, sizeof(SOCKADDR_IN));	 
	addr.sin_family = AF_INET;
	addr.sin_port = htons(port);			
	addr.sin_addr.s_addr = inet_addr(ip);	

	if( connect(s, (SOCKADDR*)&amp;addr, sizeof(SOCKADDR)) == SOCKET_ERROR )
	{
		printf(&quot;Fehler: Verbindung mit %s kann nicht hergestellt werden\n\n&quot;, ip);
		return 1; 
	}
	printf(&quot;Verbunden mit %s\n&quot;, ip);

------------------------------------------------------------------
	// Datei versenden 
	if( (file = fopen(datei, &quot;rb&quot;)) == NULL )
	{
		printf(&quot;Fehler: Datei %s kann nicht geoffnet werden\n\n&quot;, datei);
		return 1; 
	}

	printf(&quot;Sende Datei... &quot;);
	while( !feof(file) )
	{
		num = 0;
		num = fread(buf, sizeof(char), sizeof(buf), file);
		num = send(s, buf, num, 0);
		if( num == SOCKET_ERROR )
		{
			printf(&quot;\nFehler: Fehler beim senden aufgetreten\n\n&quot;);
			return 1; 
		}
		printf(&quot;.&quot;);  
	}
	printf(&quot;\nDatei erfolgreich versendet!\n\n&quot;);

	fclose(file);
	closesocket(s);
	WSACleanup();

	return 0;
}
</code></pre>
<pre><code class="language-cpp">//Empfänger (Server) empfängt ein Datei	
#include &lt;stdio.h&gt;
#include &lt;winsock2.h&gt;

int startWinsock(void)
{
	WSADATA wsa;
	return WSAStartup(MAKEWORD(2,0),&amp;wsa);
}

int main(int argc, int *argv[])
{
	SOCKET acceptSocket, s;
	SOCKADDR_IN addr;
	FILE *file;
	char buf[1024];
	int num;

	char datei[] = &quot;C:\\newfile.exe&quot;;			// Datei path
	int port = 123;							// Port

	printf(&quot;\n&quot;);

//-----------------------------------------------------------
	// Winsock initialisieren 
	if( startWinsock() != 0 )
	{
		printf(&quot;Fehler: Winsock kann nicht initialisiert werden\n\n&quot;);
		return 1; 
	}

//-----------------------------------------------------------------
	// Socket erstellen 
	acceptSocket = socket(AF_INET,SOCK_STREAM,0);
	if(acceptSocket == INVALID_SOCKET)
	{
		printf(&quot;Fehler: Socket kann nicht erstellt werden\n\n&quot;);
		return 1; 
	}

//--------------------------------------------------------
	// Socket an das Port binden 
	memset(&amp;addr,0,sizeof(SOCKADDR_IN));
	addr.sin_family = AF_INET;
	addr.sin_port = htons(port);
	addr.sin_addr.s_addr = ADDR_ANY;

	if( bind(acceptSocket, (SOCKADDR*)&amp;addr, sizeof(SOCKADDR_IN)) == SOCKET_ERROR )
	{ 
		printf(&quot;Fehler: Socket kann an das port nicht gebunden werden\n\n&quot;);
		return 1;
	}

//------------------------------------------------------------
	// Auf Verbindung warten 
	if( listen(acceptSocket,10) == SOCKET_ERROR )
	{
		printf(&quot;Fehler: listen()\n\n&quot;);
		return 1; 
	}
	printf(&quot;Warte auf Verbindung...\n&quot;);

//-----------------------------------------------------------
	// Verbindung akzeptieren 
	s = accept(acceptSocket,NULL,NULL);
	if(s == INVALID_SOCKET)
	{
		printf(&quot;Fehler: accept()\n\n&quot;);
		return 1;
	}
	printf(&quot;Verbindung akzeptiert\n&quot;);

//------------------------------------------------------------------
	// Datei empfangen 
	if( (file = fopen(datei, &quot;wb&quot;)) == NULL )
	{
		printf(&quot;Datei %s koennte zum schreiben nicht geoffnet werden\n\n&quot;, datei);
		return 1; 
	}
	printf(&quot;Datei %s zum schreiben geoffnet\n&quot;, datei);

	printf(&quot;\nEmpfange Datei...\nBitte warten... &quot;);
	while( (num = recv(s, buf, sizeof(buf), 0)) &gt; 0 )
	{
		fwrite(buf, sizeof(char), num, file);
		printf(&quot;.&quot;); 
	}
	printf(&quot;\nDatei empfangen!\n\n&quot;);
	fclose(file);
	closesocket(s);
	WSACleanup();
	return 0;
}
</code></pre>
<p>Wie du das mit dem FileName etc hinkriegst siehe oben <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
<p>Übrigens, ein 10 MB grosse Datei zu versenden wird schon eine gewiesse Zeit in Anspruch nehmen, auch bei DSL.</p>
<p>Versuch es erst mit kleineren Dateien, wenn du sicher bist, dass alles 100% funktioniert dann kannst du es auch an deinem 10 MB Datei ausüben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/906818</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/906818</guid><dc:creator><![CDATA[Ausländer]]></dc:creator><pubDate>Wed, 02 Nov 2005 21:03:21 GMT</pubDate></item><item><title><![CDATA[Reply to Winsock datei sende problem on Thu, 03 Nov 2005 15:22:08 GMT]]></title><description><![CDATA[<p>Also senden klappt jetzt.Danke <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /> .<br />
Aber ich kann die exe dann nicht starten. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /><br />
Da Flimmert kurz auf und sofort wieder aus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/907475</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/907475</guid><dc:creator><![CDATA[Stefan311]]></dc:creator><pubDate>Thu, 03 Nov 2005 15:22:08 GMT</pubDate></item><item><title><![CDATA[Reply to Winsock datei sende problem on Thu, 03 Nov 2005 16:05:06 GMT]]></title><description><![CDATA[<p>Was für ne exe???<br />
Vieleicht ist das eine Konsolenanwendung??? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /><br />
Bei mir hat das einwandfrei funktioniert <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/907500</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/907500</guid><dc:creator><![CDATA[Ausländer]]></dc:creator><pubDate>Thu, 03 Nov 2005 16:05:06 GMT</pubDate></item><item><title><![CDATA[Reply to Winsock datei sende problem on Thu, 03 Nov 2005 16:17:08 GMT]]></title><description><![CDATA[<p>Also hab jetzt nochmal alles extra überprüft, und muss sagen das es funktioniert bei mir.</p>
<p>Vieleicht machst du was falsch?<br />
Sender erwartet eine &quot;file.exe&quot; Datei auf Laufwerk C:\ zum versenden.<br />
Emfänger schreibt dann emfangene Datei in C:\newfile.exe.</p>
<p>Warum es bei dir nicht geht weiss ich nicht, aber ich vermutte das du eine<br />
Konsolenanwendung versendet hast, und die startet mann auch normalerweise<br />
aus Konsole/Eingabeaufforderung aus. Am sonsten passiert das wovon du erzählt<br />
hast --&gt; &quot;Flimmert kurz auf und sofort wieder aus&quot;.</p>
<p>Grüß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/907513</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/907513</guid><dc:creator><![CDATA[Ausländer]]></dc:creator><pubDate>Thu, 03 Nov 2005 16:17:08 GMT</pubDate></item><item><title><![CDATA[Reply to Winsock datei sende problem on Thu, 03 Nov 2005 16:31:38 GMT]]></title><description><![CDATA[<p>Eigentlich ist es Keine konsolen anwendung. Aber Wenn ich es</p>
<p>nun in der Konsole öffne steht da Programm zu groß für arbeitsspeicher.<br />
Das komische die datei beim server kann ich noch starten(Bei mir ist Server Sender<br />
und Client empfänger) nur die gedownloadete datei will nicht.Lieder hingegen<br />
klappen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/907525</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/907525</guid><dc:creator><![CDATA[Stefan311]]></dc:creator><pubDate>Thu, 03 Nov 2005 16:31:38 GMT</pubDate></item><item><title><![CDATA[Reply to Winsock datei sende problem on Thu, 03 Nov 2005 16:37:41 GMT]]></title><description><![CDATA[<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<p>Vergleiche mal die Größen von beiden Dateien...<br />
Da leuft was schief bei dir, ich kann hier nur eins sagen:<br />
Poste mal den Code dann sehen wir was du falsch machst <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="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/907528</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/907528</guid><dc:creator><![CDATA[Ausländer]]></dc:creator><pubDate>Thu, 03 Nov 2005 16:37:41 GMT</pubDate></item><item><title><![CDATA[Reply to Winsock datei sende problem on Thu, 03 Nov 2005 16:39:16 GMT]]></title><description><![CDATA[<p>Stefan311 schrieb:</p>
<blockquote>
<p>Bei mir ist Server Sender<br />
und Client empfänger)</p>
</blockquote>
<p>Im Grunde ist es egal nachdem Verbindung aufgebaut ist</p>
]]></description><link>https://www.c-plusplus.net/forum/post/907530</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/907530</guid><dc:creator><![CDATA[Ausländer]]></dc:creator><pubDate>Thu, 03 Nov 2005 16:39:16 GMT</pubDate></item><item><title><![CDATA[Reply to Winsock datei sende problem on Thu, 03 Nov 2005 16:59:55 GMT]]></title><description><![CDATA[<p>Dtei größe stimmt doch nicht.Empfangene=1,01 MB (1.060.855 Bytes),Original=1,01 MB (1.060.859 Bytes)<br />
Server(ist hoffentlich ein wenig verstänlicher ich hab jetzt erstmal dein code eingesetzt)</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt; 
#include &lt;process.h&gt;
#include &lt;winsock2.h&gt; 
#include &lt;iostream&gt;
#include &lt;stdio.h&gt; 
#include &lt;stdlib.h&gt;
#include &lt;conio.h&gt;
#include &lt;fstream&gt;
#include &lt;sys/types.h&gt;
#include &lt;sys/stat.h&gt;
using namespace std;
void warte(void *ch);
int startWinsock(void); 
int a=0;
int i;
int b=0;

int end=0;
 long rc;
 SOCKET cs; 
 char ausgabe1[300];
int main() 
{ 

char test[300];

  SOCKET acceptSocket; 
FILE *file; 
    char buf[1024]; 
    int num; 
  SOCKADDR_IN addr; 

  // Winsock starten 
char datei[] = &quot;update/upms.exe&quot;;
  rc=startWinsock(); 

  if(rc!=0) 

  { 

    printf(&quot;Fehler: startWinsock, fehler code: %d\n&quot;,rc); 

    return 1; 

  } 

  else 

  { 

    printf(&quot;Winsock gestartet!\n&quot;); 

  } 

  // Socket erstellen 

  acceptSocket=socket(AF_INET,SOCK_STREAM,0); 

  if(acceptSocket==INVALID_SOCKET) 

  { 

    printf(&quot;Fehler: Der Socket konnte nicht erstellt werden, fehler code: %d\n&quot;,WSAGetLastError()); 

    return 1; 

  } 

  else 

  { 

    printf(&quot;Socket erstellt!\n&quot;); 

  } 

	a=1;
memset(&amp;addr,0,sizeof(SOCKADDR_IN)); 

addr.sin_family=AF_INET; 

addr.sin_port=htons(81); 

addr.sin_addr.s_addr=ADDR_ANY; 

rc=bind(acceptSocket,(SOCKADDR*)&amp;addr,sizeof(SOCKADDR_IN)); 
listen:
if(rc==SOCKET_ERROR) 

{ 

  printf(&quot;Fehler: bind, fehler code: %d\n&quot;,WSAGetLastError()); 

  return 1; 

} 

else 

{ 

  printf(&quot;Socket an port 81 gebunden\n&quot;); 

} 

rc=listen(acceptSocket,10); 

if(rc==SOCKET_ERROR) 

{ 

  printf(&quot;Fehler: listen, fehler code: %d\n&quot;,WSAGetLastError()); 

  return 1; 

} 

else 

{ 

  printf(&quot;acceptSocket ist im listen Modus....\n&quot;);  

} 

cs=accept(acceptSocket,NULL,NULL);

if(cs==INVALID_SOCKET) 

{ 
b=1;
  printf(&quot;Fehler: accept, fehler code: %d\n&quot;,WSAGetLastError()); 

  return 1; 

} 

else 

{ 

  printf(&quot;Neue Verbindung wurde akzeptiert!\n&quot;); 

} 

if(rc==SOCKET_ERROR) 
{
	cout&lt;&lt;&quot;Fehler: Sende port reagiert nicht!&quot;;

}

rc = recv(cs,buf,8,0);
if(buf[0]=='2' &amp;&amp; buf[1]=='.' &amp;&amp; buf[2]=='5' )
{
	buf[0]='0';
		rc = send(cs,buf,3,0);
		cout&lt;&lt;&quot;\nBitte neu starten update Fertig!&quot;;
		cin.get();
		return 0;
}
else
{

buf[0]='1';
		rc = send(cs,buf,3,0);

}

char *buf2;
	buf2=new char(1024);

if( (file = fopen(datei, &quot;rb&quot;)) == NULL ) 
    { 
        printf(&quot;Fehler: Datei %s kann nicht geoffnet werden\n\n&quot;, datei); 
        return 1; 
    } 

 printf(&quot;Sende Datei... &quot;); 
    while( !feof(file) ) 
    { 
        num = 0; 
        num = fread(buf, sizeof(char), sizeof(buf), file); 
        num = send(cs, buf, num, 0); 
        if( num == SOCKET_ERROR ) 
        { 
            printf(&quot;\nFehler: Fehler beim senden aufgetreten\n\n&quot;); 
            return 1; 
        } 
        printf(&quot;.&quot;);   
    } 
    printf(&quot;\nDatei erfolgreich versendet!\n\n&quot;); 

    fclose(file); 
    closesocket(cs); 
    WSACleanup(); 

    cout&lt;&lt;&quot;\nBitte neu starten update Fertig!&quot;;
cin.get();
return 0; 
}

int startWinsock(void) 

{ 

  WSADATA wsa; 

  return WSAStartup(MAKEWORD(2,0),&amp;wsa); 

}
</code></pre>
<p>Client:</p>
<pre><code class="language-cpp">#include &quot;headers\magicaklass.h&quot;
using namespace std;

int update()
{

//Prototypen

int startWinsock(void);
 long getAddrFromString(char* hostnameOrIp, SOCKADDR_IN* addr);

  char ausgabe1[300];
 	int b=0;
int end=0;
  	long rc;
SOCKET s; 
  SOCKADDR_IN addr; 

long getAddrFromString(char* hostnameOrIp, SOCKADDR_IN* addr);
  char buf[200];
  char test[255];
  char hostname1[200];	

/*hostname1[0]='1';
hostname1[1]='2';
hostname1[2]='7';
hostname1[3]='.';
hostname1[4]='0';
hostname1[5]='.';
hostname1[6]='0';
hostname1[7]='.';
hostname1[8]='1';*/
//hostname1[9]='i';
//hostname1[10]='l';
/*hostname1[11]='a';
hostname1[12]='s';
hostname1[13]='.';
hostname1[14]='d';
hostname1[15]='y';
hostname1[16]='n';
hostname1[17]='d';
hostname1[18]='n';
hostname1[19]='s';
hostname1[20]='.';
hostname1[21]='o';
hostname1[22]='r';
hostname1[23]='g';*/

gets(hostname1);
gets(hostname1);

 rc=startWinsock(); 
  if(rc!=0)

  {

    printf(&quot;Fehler: Update kann nicht ausgeführt werden.\nstartWinsock, fehler code: %d\n&quot;,rc);

    return 1;

  }

  s=socket(AF_INET,SOCK_STREAM,0); 

if(s==INVALID_SOCKET) 

{ 

  printf(&quot;Fehler: Update kann nich ausgeführt werden.\nSocketfehler code: %d\n&quot;,WSAGetLastError()); 

  return 1; 

} 

   // we use the overloaded &lt;&lt;

 memset(&amp;addr,0,sizeof(SOCKADDR_IN)); // zuerst alles auf 0 setzten  

addr.sin_family=AF_INET; 

addr.sin_port=htons(81); // wir verwenden mal port 12345 

  rc=getAddrFromString(hostname1,&amp;addr);
 rc=connect(s,(SOCKADDR*)&amp;addr,sizeof(SOCKADDR));

if(rc==SOCKET_ERROR)  
  {    printf(&quot;Fehler keine Verbindung zum Host!&quot;);   
  cin.get();
  cin.get();
   Hauptmenue(); 
   }

buf[0]='2';
buf[1]='.';
buf[2]='5';
rc = send(s,buf,5,0);
rc = recv(s,buf,7,0);
if(buf[0]=='0')
{
	cout&lt;&lt;&quot;\nSie haben bereits die neueste Version.\n&quot;;
	Hauptmenue();
}

	char datei[] = &quot;upms.exe&quot;;            // Datei path 
 int num; 
				char buf2[1024];
FILE *file; 
file = fopen(datei, &quot;wb&quot;);
    printf(&quot;Datei %s zum schreiben geoffnet\n&quot;, datei); 
cin.get();

    printf(&quot;\nEmpfange Datei...\nBitte warten... &quot;); 
    while( (num = recv(s, buf, sizeof(buf), 0)) &gt; 0 ) 
    { 
        fwrite(buf, sizeof(char), num, file); 
        printf(&quot;.&quot;); 
    } 
    printf(&quot;\nDatei empfangen!\n\n&quot;); 
    fclose(file); 
    closesocket(s); 
    WSACleanup(); 

cout&lt;&lt;&quot;\nDas Programm wird jetzt ausgeschaltet.F&quot;&lt;&lt;(char)129&lt;&lt;&quot;hren sie bitte upsm.exe aus.\n&quot;;
Sleep(3000);

return 0;

} 

int startWinsock(void) 

{ 

  WSADATA wsa; 

  return WSAStartup(MAKEWORD(2,0),&amp;wsa); 

}
    long getAddrFromString(char* hostnameOrIp, SOCKADDR_IN* addr)

{

  long rc;

  unsigned long ip;

  HOSTENT* he;
  // Parameter prüfen 

  if(hostnameOrIp==NULL || addr==NULL)

    return SOCKET_ERROR;
  // eine IP in hostnameOrIp ? 

  ip=inet_addr(hostnameOrIp);
  // bei einem fehler liefert inet_addr den Rückgabewert INADDR_NONE 

  if(ip!=INADDR_NONE)

  {

    addr-&gt;sin_addr.s_addr=ip;

    return 0;

  }

  else

  {

    //Hostname in hostnameOrIp auflösen 

    he=gethostbyname(hostnameOrIp);

    if(he==NULL)

    {

      return SOCKET_ERROR;

    }

    else

    {

      //die 4 Bytes der IP von he nach addr kopieren 

      memcpy(&amp;(addr-&gt;sin_addr),he-&gt;h_addr_list[0],4);

    }

    return 0;

  }

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/907549</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/907549</guid><dc:creator><![CDATA[Stefan311]]></dc:creator><pubDate>Thu, 03 Nov 2005 16:59:55 GMT</pubDate></item><item><title><![CDATA[Reply to Winsock datei sende problem on Thu, 03 Nov 2005 19:30:58 GMT]]></title><description><![CDATA[<p>Ah du kake <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /></p>
<p>Stefan ich gebe dir ein Rat, lösche alles und fange von vorne an.</p>
<p>--------------------------------------------------------------------------<br />
Falsch:<br />
rc = send(s,buf,5,0);<br />
rc = recv(s,buf,7,0);<br />
Richtig:<br />
rc = send(s, buf, strlen(buf), 0);<br />
rc = recv(s, buf, sizeof(buf), 0);<br />
____________________________________________________________________________</p>
<p>gets(hostname1); wieso gleich zwei mal? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /><br />
gets(hostname1);<br />
___________________________________________________________________________</p>
<p>/<em>hostname1[0]='1';<br />
hostname1[1]='2';<br />
hostname1[2]='7';<br />
hostname1[3]='.';<br />
hostname1[4]='0';<br />
hostname1[5]='.';<br />
hostname1[6]='0';<br />
hostname1[7]='.';<br />
hostname1[8]='1';</em>/<br />
//hostname1[9]='i';<br />
//hostname1[10]='l';<br />
/<em>hostname1[11]='a';<br />
hostname1[12]='s';<br />
hostname1[13]='.';<br />
hostname1[14]='d';<br />
hostname1[15]='y';<br />
hostname1[16]='n';<br />
hostname1[17]='d';<br />
hostname1[18]='n';<br />
hostname1[19]='s';<br />
hostname1[20]='.';<br />
hostname1[21]='o';<br />
hostname1[22]='r';<br />
hostname1[23]='g';</em>/</p>
<p>Was ist das?????? dafür gibt es strcpy();<br />
_______________________________________________________________________</p>
<p>int update()<br />
{</p>
<p>//Prototypen</p>
<p>int startWinsock(void);<br />
long getAddrFromString(char* hostnameOrIp, SOCKADDR_IN* addr);</p>
<p>char ausgabe1[300];<br />
int b=0;<br />
int end=0;<br />
long rc;<br />
SOCKET s;<br />
SOCKADDR_IN addr;</p>
<p>Prototypen inerhalb einer Funktion ??? hmmm <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 />
______________________________________________________________________________</p>
<p>Falsch<br />
char datei[] = &quot;update/upms.exe&quot;;<br />
Richtig<br />
char datei[] = &quot;C:\\blabla\\update\\upms.exe&quot;;</p>
<p>__________________________________________________________________</p>
<p>Falsch<br />
char *buf2;<br />
buf2=new char(1024); // &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;</p>
<p>Richtig<br />
char *buf2;<br />
buf2 = new char[1024];</p>
<p>An freigabe denken &quot;delete&quot;<br />
_____________________________________________________________________</p>
<p>Und das sind noch lange nicht alle Fehler <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /><br />
Also schau nochmal den Beispiel von oben, und besser<br />
kompiliere die beiden und starte sie dann.<br />
Ich wundere mich dass da überhaupt was funktioniert hat.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/907586</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/907586</guid><dc:creator><![CDATA[Ausländer]]></dc:creator><pubDate>Thu, 03 Nov 2005 19:30:58 GMT</pubDate></item><item><title><![CDATA[Reply to Winsock datei sende problem on Thu, 03 Nov 2005 18:36:57 GMT]]></title><description><![CDATA[<p>Gut das it strcpy wuste ich nicht und mit strlen auch nicht.<br />
Ups &gt;&gt; Prototypen<br />
mitchar datei[] = &quot;update/upms.exe&quot;;<br />
das guckt er nur um programm ordner wo es ausgeführt wird.<br />
und / geht auch anstatt \.<br />
Aber gut ich werdenoch mal alles komplett neu schreiben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/907617</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/907617</guid><dc:creator><![CDATA[Stefan311]]></dc:creator><pubDate>Thu, 03 Nov 2005 18:36:57 GMT</pubDate></item></channel></rss>