<?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[UDP Problem! Kann nach recvfrom die addr nicht mehr verwenden]]></title><description><![CDATA[<p>Guten Abend,<br />
ich habe folgendes Problem:<br />
Nach dem recvfrom:</p>
<pre><code class="language-cpp">bytes = recvfrom(sd, buf, sizeof(buf), 0, (struct sockaddr*)&amp;addr, &amp;addr_len);
</code></pre>
<p>speichere ich die addr wie folgt ab:</p>
<pre><code class="language-cpp">clients.push_back(addr);
</code></pre>
<p>Eine Antwort funktioniert nur unmittelbar danach:</p>
<pre><code class="language-cpp">sendto(sd, buf, bytes, 0, (struct sockaddr*)&amp;clients[i], sizeof(addr));
</code></pre>
<p>Zu einem späteren Zeitpunkt kann ich nicht mehr an &amp;clients[i] senden. Ich verstehe einfach nicht wieso.<br />
Die Deklarationen sind wie folgt:</p>
<pre><code class="language-cpp">vector&lt;struct sockaddr_in&gt; clients;
struct sockaddr_in addr;
</code></pre>
<p>Ich bin fuer jede Hilfe dankbar.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/271834/udp-problem-kann-nach-recvfrom-die-addr-nicht-mehr-verwenden</link><generator>RSS for Node</generator><lastBuildDate>Sat, 29 Aug 2026 00:10:08 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/271834.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 04 Aug 2010 17:29:54 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to UDP Problem! Kann nach recvfrom die addr nicht mehr verwenden on Wed, 04 Aug 2010 17:29:54 GMT]]></title><description><![CDATA[<p>Guten Abend,<br />
ich habe folgendes Problem:<br />
Nach dem recvfrom:</p>
<pre><code class="language-cpp">bytes = recvfrom(sd, buf, sizeof(buf), 0, (struct sockaddr*)&amp;addr, &amp;addr_len);
</code></pre>
<p>speichere ich die addr wie folgt ab:</p>
<pre><code class="language-cpp">clients.push_back(addr);
</code></pre>
<p>Eine Antwort funktioniert nur unmittelbar danach:</p>
<pre><code class="language-cpp">sendto(sd, buf, bytes, 0, (struct sockaddr*)&amp;clients[i], sizeof(addr));
</code></pre>
<p>Zu einem späteren Zeitpunkt kann ich nicht mehr an &amp;clients[i] senden. Ich verstehe einfach nicht wieso.<br />
Die Deklarationen sind wie folgt:</p>
<pre><code class="language-cpp">vector&lt;struct sockaddr_in&gt; clients;
struct sockaddr_in addr;
</code></pre>
<p>Ich bin fuer jede Hilfe dankbar.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1936247</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1936247</guid><dc:creator><![CDATA[essteeu]]></dc:creator><pubDate>Wed, 04 Aug 2010 17:29:54 GMT</pubDate></item><item><title><![CDATA[Reply to UDP Problem! Kann nach recvfrom die addr nicht mehr verwenden on Wed, 04 Aug 2010 22:56:33 GMT]]></title><description><![CDATA[<p>mhh sollte ein &quot;struct sockaddr_in&quot; nicht die Ziel IP Adresse repräsentieren? Wenn nein, wofür steht dieser Datentyp denn? Und weshalb hat er so eine kurze Laufzeit?<br />
Ich komme einfach nicht weiter....</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1936371</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1936371</guid><dc:creator><![CDATA[essteeu]]></dc:creator><pubDate>Wed, 04 Aug 2010 22:56:33 GMT</pubDate></item><item><title><![CDATA[Reply to UDP Problem! Kann nach recvfrom die addr nicht mehr verwenden on Thu, 05 Aug 2010 06:16:30 GMT]]></title><description><![CDATA[<p>Welchen Fehler erhälst Du denn?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1936415</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1936415</guid><dc:creator><![CDATA[Roger Wilco]]></dc:creator><pubDate>Thu, 05 Aug 2010 06:16:30 GMT</pubDate></item><item><title><![CDATA[Reply to UDP Problem! Kann nach recvfrom die addr nicht mehr verwenden on Thu, 05 Aug 2010 06:32:00 GMT]]></title><description><![CDATA[<p>http fehler?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1936416</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1936416</guid><dc:creator><![CDATA[http?]]></dc:creator><pubDate>Thu, 05 Aug 2010 06:32:00 GMT</pubDate></item><item><title><![CDATA[Reply to UDP Problem! Kann nach recvfrom die addr nicht mehr verwenden on Thu, 05 Aug 2010 06:33:45 GMT]]></title><description><![CDATA[<p>http? schrieb:</p>
<blockquote>
<p>http fehler?</p>
</blockquote>
<p>OMG OMG OMG OMG OMG OMG OMG OMG OMG OMG OMG OMG OMG OMG OMG OMG OMG OMG OMG OMG OMG OMG OMG OMG OMG OMG OMG OMG OMG OMG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1936417</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1936417</guid><dc:creator><![CDATA[OMG OMG OMG]]></dc:creator><pubDate>Thu, 05 Aug 2010 06:33:45 GMT</pubDate></item><item><title><![CDATA[Reply to UDP Problem! Kann nach recvfrom die addr nicht mehr verwenden on Thu, 05 Aug 2010 11:21:28 GMT]]></title><description><![CDATA[<p>Ich fände es schön, wenn mein Problem ernst behandelt wird.<br />
Ich erhalte keinen Fehler, das senden zum &quot;gespeicherten&quot; Client kommt einfach nicht an.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1936554</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1936554</guid><dc:creator><![CDATA[essteeu]]></dc:creator><pubDate>Thu, 05 Aug 2010 11:21:28 GMT</pubDate></item><item><title><![CDATA[Reply to UDP Problem! Kann nach recvfrom die addr nicht mehr verwenden on Thu, 05 Aug 2010 12:26:03 GMT]]></title><description><![CDATA[<p>D.h. sendto() gibt keinen Fehler zurück?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1936595</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1936595</guid><dc:creator><![CDATA[Roger Wilco]]></dc:creator><pubDate>Thu, 05 Aug 2010 12:26:03 GMT</pubDate></item><item><title><![CDATA[Reply to UDP Problem! Kann nach recvfrom die addr nicht mehr verwenden on Thu, 05 Aug 2010 12:59:15 GMT]]></title><description><![CDATA[<p>Was steht denn zu dem späteren Zeitpunkt in &amp;clients[i] drin?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1936607</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1936607</guid><dc:creator><![CDATA[theta]]></dc:creator><pubDate>Thu, 05 Aug 2010 12:59:15 GMT</pubDate></item><item><title><![CDATA[Reply to UDP Problem! Kann nach recvfrom die addr nicht mehr verwenden on Thu, 05 Aug 2010 14:40:24 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/4570">@Roger</a>:<br />
Doch, sendto gibt -1 zurück.</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/19131">@theta</a><br />
wie oder als was kann ich das ausgeben?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1936658</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1936658</guid><dc:creator><![CDATA[essteeu]]></dc:creator><pubDate>Thu, 05 Aug 2010 14:40:24 GMT</pubDate></item><item><title><![CDATA[Reply to UDP Problem! Kann nach recvfrom die addr nicht mehr verwenden on Thu, 05 Aug 2010 15:06:09 GMT]]></title><description><![CDATA[<p>essteeu schrieb:</p>
<blockquote>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/4570">@Roger</a>:<br />
Doch, sendto gibt -1 zurück.</p>
</blockquote>
<p><a href="http://msdn.microsoft.com/en-us/library/ms740148%28VS.85%29.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms740148%28VS.85%29.aspx</a><br />
dort steht: Return value is SOCKET_ERROR in case of an error... oder so ähnlich.</p>
<p>wenn du dann noch das hier weist: <code>#define SOCKET_ERROR -1</code> , weist du, dass was mit deinem Fkt-Aufruf nicht stimmt.</p>
<p>Guck dir mal <code>WSAGetLastError()</code> an, oder wie das genau heißt...</p>
<p>bb</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1936665</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1936665</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Thu, 05 Aug 2010 15:06:09 GMT</pubDate></item><item><title><![CDATA[Reply to UDP Problem! Kann nach recvfrom die addr nicht mehr verwenden on Thu, 05 Aug 2010 15:19:44 GMT]]></title><description><![CDATA[<p>unskilled schrieb:</p>
<blockquote>
<p>essteeu schrieb:</p>
<blockquote>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/4570">@Roger</a>:<br />
Doch, sendto gibt -1 zurück.</p>
</blockquote>
<p><a href="http://msdn.microsoft.com/en-us/library/ms740148%28VS.85%29.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms740148%28VS.85%29.aspx</a><br />
dort steht: Return value is SOCKET_ERROR in case of an error... oder so ähnlich.</p>
<p>wenn du dann noch das hier weist: <code>#define SOCKET_ERROR -1</code> , weist du, dass was mit deinem Fkt-Aufruf nicht stimmt.</p>
<p>Guck dir mal <code>WSAGetLastError()</code> an, oder wie das genau heißt...</p>
<p>bb</p>
</blockquote>
<p>Ich verstehe deine Aussage nicht. Noch eine Zusatzinfo, das Programm läuft unter Linux.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1936672</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1936672</guid><dc:creator><![CDATA[essteeu]]></dc:creator><pubDate>Thu, 05 Aug 2010 15:19:44 GMT</pubDate></item><item><title><![CDATA[Reply to UDP Problem! Kann nach recvfrom die addr nicht mehr verwenden on Thu, 05 Aug 2010 15:39:50 GMT]]></title><description><![CDATA[<p>dann gib mal in der konsole <code>man sendto</code> an und dort mal, was die über den return-wert schreiben.<br />
ansonsten halte ich - auch unter linux - die <code>-1</code> für einen fehlercode...</p>
<p>bb</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1936681</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1936681</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Thu, 05 Aug 2010 15:39:50 GMT</pubDate></item><item><title><![CDATA[Reply to UDP Problem! Kann nach recvfrom die addr nicht mehr verwenden on Thu, 05 Aug 2010 15:47:17 GMT]]></title><description><![CDATA[<p>essteeu schrieb:</p>
<blockquote>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/19131">@theta</a><br />
wie oder als was kann ich das ausgeben?</p>
</blockquote>
<p>Mit dem Debugger.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1936687</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1936687</guid><dc:creator><![CDATA[theta]]></dc:creator><pubDate>Thu, 05 Aug 2010 15:47:17 GMT</pubDate></item><item><title><![CDATA[Reply to UDP Problem! Kann nach recvfrom die addr nicht mehr verwenden on Fri, 06 Aug 2010 05:09:06 GMT]]></title><description><![CDATA[<p>essteeu schrieb:</p>
<blockquote>
<p>[url] [...]</p>
<p>unskilled schrieb:</p>
<blockquote>
<p>Guck dir mal <code>WSAGetLastError()</code> an, oder wie das genau heißt...</p>
</blockquote>
<p>Ich verstehe deine Aussage nicht. Noch eine Zusatzinfo, das Programm läuft unter Linux.</p>
</blockquote>
<pre><code class="language-cpp">#include &lt;errno.h&gt;

int socketErrCode = errno();
</code></pre>
<p><a href="http://beej.us/guide/bgnet/output/html/multipage/errnoman.html" rel="nofollow">http://beej.us/guide/bgnet/output/html/multipage/errnoman.html</a><br />
<a href="http://beej.us/guide/bgnet/output/html/multipage/perrorman.html" rel="nofollow">http://beej.us/guide/bgnet/output/html/multipage/perrorman.html</a></p>
<blockquote>
<p>This is the variable that holds error information for a lot of system calls. If you'll recall, things like socket() and listen() return -1 on error, and they set the exact value of errno to let you know specifically which error occurred.</p>
<p>[...]</p>
<p>...you can call perror() or strerror() to get a human-readable version of the error</p>
</blockquote>
<p>Viele Grüße</p>
<p>Roger Wilco</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1936878</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1936878</guid><dc:creator><![CDATA[Roger Wilco]]></dc:creator><pubDate>Fri, 06 Aug 2010 05:09:06 GMT</pubDate></item><item><title><![CDATA[Reply to UDP Problem! Kann nach recvfrom die addr nicht mehr verwenden on Sun, 15 Aug 2010 16:35:40 GMT]]></title><description><![CDATA[<p>Guten Abend,<br />
entschuldigt das ich diesen Thread hier wieder schreibe. Ich hatte in den letzten Tagen ziemlich viel zu tun.<br />
Mittlerweile habe ich folgende Aussage durch den Debugger erhalten:</p>
<pre><code class="language-cpp">clients[client] = (sockaddr_in &amp;) @0x8133fc0: {
sin_family = 2,
sin_port = 16081,
sin_addr = {
s_addr = 201500864
},
sin_zero = &quot;\000\000\000\000\000\000\000&quot;
}
</code></pre>
<p>Ich bin für eure Hilfe dankbar <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title="=)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1940307</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1940307</guid><dc:creator><![CDATA[essteeu]]></dc:creator><pubDate>Sun, 15 Aug 2010 16:35:40 GMT</pubDate></item></channel></rss>