<?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[Sock Send Methode]]></title><description><![CDATA[<p>Hi! Ich wollte mal fragen, ob meine Methode für send so in Orndung ist:</p>
<pre><code class="language-cpp">long MultiSocket::Send(char* szSend, int nLength)
{
	return Send(szSend, nLength, Socket);
}

long MultiSocket::Send(char* szSend, int nLength, SOCKET Sock)
{
	long rc = -1;
	long is = 0;
	long to = nLength;
	char* szTo = new char[strlen(szSend) + 2];

	while(is &lt;= (to -1))
	{
		for(int i = 0; i &lt; to; i++)
		{
			szTo[i] = szSend[is + i];
		}
		szTo[strlen(szSend) + 0] = '\0';
		szTo[strlen(szSend) + 1] = '\0';

		#ifdef DEBUG
			std::cout &lt;&lt; &quot;Send: &quot; &lt;&lt; to &lt;&lt; &quot;:&quot; &lt;&lt; is &lt;&lt; &quot;;&quot; &lt;&lt; (to - is) &lt;&lt; &quot;#&quot; &lt;&lt; szSend &lt;&lt; &quot;-&quot; &lt;&lt; szTo &lt;&lt; std::endl;
		#endif

		rc = send(Sock, szTo, (to - is + 1), NULL);
		if(rc == SOCKET_ERROR)
		{
			std::cout &lt;&lt; &quot;Send error: &quot; &lt;&lt; WSAGetLastError() &lt;&lt; std::endl;
			return WSAGetLastError();
		}
		is += rc;
	}

	delete [] szTo;
	return 0;
}
</code></pre>
<p>Send ist ja leider keine Garantie, dass alle angegebenen Bytes auch gesendet werden und so hab ich mir diese Methode augedacht. Jetzt möchte ich noch sicher gehen, dadd diese auch zu 100% funktioniert.<br />
Gruss, fushigi</p>
<p>EDIT: Kleine Verbesserung am Code.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/285665/sock-send-methode</link><generator>RSS for Node</generator><lastBuildDate>Fri, 21 Aug 2026 06:08:27 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/285665.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 25 Apr 2011 17:40:08 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Sock Send Methode on Mon, 25 Apr 2011 17:53:46 GMT]]></title><description><![CDATA[<p>Hi! Ich wollte mal fragen, ob meine Methode für send so in Orndung ist:</p>
<pre><code class="language-cpp">long MultiSocket::Send(char* szSend, int nLength)
{
	return Send(szSend, nLength, Socket);
}

long MultiSocket::Send(char* szSend, int nLength, SOCKET Sock)
{
	long rc = -1;
	long is = 0;
	long to = nLength;
	char* szTo = new char[strlen(szSend) + 2];

	while(is &lt;= (to -1))
	{
		for(int i = 0; i &lt; to; i++)
		{
			szTo[i] = szSend[is + i];
		}
		szTo[strlen(szSend) + 0] = '\0';
		szTo[strlen(szSend) + 1] = '\0';

		#ifdef DEBUG
			std::cout &lt;&lt; &quot;Send: &quot; &lt;&lt; to &lt;&lt; &quot;:&quot; &lt;&lt; is &lt;&lt; &quot;;&quot; &lt;&lt; (to - is) &lt;&lt; &quot;#&quot; &lt;&lt; szSend &lt;&lt; &quot;-&quot; &lt;&lt; szTo &lt;&lt; std::endl;
		#endif

		rc = send(Sock, szTo, (to - is + 1), NULL);
		if(rc == SOCKET_ERROR)
		{
			std::cout &lt;&lt; &quot;Send error: &quot; &lt;&lt; WSAGetLastError() &lt;&lt; std::endl;
			return WSAGetLastError();
		}
		is += rc;
	}

	delete [] szTo;
	return 0;
}
</code></pre>
<p>Send ist ja leider keine Garantie, dass alle angegebenen Bytes auch gesendet werden und so hab ich mir diese Methode augedacht. Jetzt möchte ich noch sicher gehen, dadd diese auch zu 100% funktioniert.<br />
Gruss, fushigi</p>
<p>EDIT: Kleine Verbesserung am Code.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2054094</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2054094</guid><dc:creator><![CDATA[fushigi]]></dc:creator><pubDate>Mon, 25 Apr 2011 17:53:46 GMT</pubDate></item><item><title><![CDATA[Reply to Sock Send Methode on Mon, 25 Apr 2011 18:05:32 GMT]]></title><description><![CDATA[<p>Das Umkopieren des zu sendenden Daten halte ich für sinnlos<sup>*</sup>. Du kannst problemlos mit dem übergebenen Speicherbereich arbeiten und zur Not einen Zeiger in die Mitte des Arrays verwenden.</p>
<p><sup>*</sup>außerdem ist es nicht gerade sicher wie du mit strlen arbeitest - ich glaube nicht, daß der übergebene Speicherblock null-terminiert ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2054115</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2054115</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 25 Apr 2011 18:05:32 GMT</pubDate></item><item><title><![CDATA[Reply to Sock Send Methode on Mon, 25 Apr 2011 23:21:14 GMT]]></title><description><![CDATA[<p>Dein Code ist grauenhaft. Keine Lust mir das anzusehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2054277</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2054277</guid><dc:creator><![CDATA[314159265358979]]></dc:creator><pubDate>Mon, 25 Apr 2011 23:21:14 GMT</pubDate></item><item><title><![CDATA[Reply to Sock Send Methode on Tue, 26 Apr 2011 05:49:38 GMT]]></title><description><![CDATA[<p>fushigi schrieb:</p>
<blockquote>
<p>Send ist ja leider keine Garantie, dass alle angegebenen Bytes auch gesendet werden</p>
</blockquote>
<p>Das kommt darauf an: Unter Windows mit einem blockierenden Socket macht send alles oder nichts.<br />
Für das Gegenstück recv gilt das nicht - dort muss immer geprüft werden, ob die erwartete Datenmenge geliefert worden ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2054285</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2054285</guid><dc:creator><![CDATA[Belli]]></dc:creator><pubDate>Tue, 26 Apr 2011 05:49:38 GMT</pubDate></item><item><title><![CDATA[Reply to Sock Send Methode on Tue, 26 Apr 2011 11:24:02 GMT]]></title><description><![CDATA[<p>314159265358979 schrieb:</p>
<blockquote>
<p>Dein Code ist grauenhaft. Keine Lust mir das anzusehen.</p>
</blockquote>
<p>Den Post hättest du dir sparen können.<br />
(Das selbe gilt für mich, wollte es aber nur loswerden)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2054455</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2054455</guid><dc:creator><![CDATA[PI ist unnötig]]></dc:creator><pubDate>Tue, 26 Apr 2011 11:24:02 GMT</pubDate></item></channel></rss>