<?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[Problem Socket in c++ Programm hinzuzufügen]]></title><description><![CDATA[<p>Hallo,<br />
ich habe ein Problem, ich möchte gerne das Array Values<br />
über einen Socket an ein anderes Programm schicken.</p>
<p>Wie fange ich da an, bzw. was muss ich da machen, wo starte ich am besten?</p>
<p>Das Programm schaut so aus:<br />
[code][cpp]<br />
#include &quot;UrgCtrl.h&quot;<br />
#include &lt;cstdlib&gt;</p>
<p>using namespace qrk;<br />
using namespace std;</p>
<p>//! main<br />
int main(int argc, char *argv[])<br />
{<br />
const char device[] = &quot;COM4&quot;;<br />
//const char device[] = &quot;/dev/ttyACM0&quot;;</p>
<p>UrgCtrl urg;<br />
urg.connect(device);<br />
/* if (! urg.connect(device)) {<br />
printf(&quot;UrgCtrl::connect: %s\n&quot;, urg.what());<br />
getchar();<br />
exit(1);<br />
}*/</p>
<p>// GD ƒRƒ}ƒ“ƒh‚ÅŽw’è‚³‚ê‚½‰ñ�”‚¾‚¯ƒXƒLƒƒƒ“‚ð�s‚¢�A�o—Í‚·‚é<br />
enum { CaptureTimes = 1 };<br />
double values[725];<br />
for (int i = 0; i &lt; CaptureTimes; ++i)<br />
{<br />
long timestamp = 0;<br />
vector&lt;long&gt; data;</p>
<p>// Žæ“¾<br />
int n = urg.capture(data, &amp;timestamp);</p>
<p>// �o—Í<br />
// printf(&quot;timestamp: %ld\n&quot;, timestamp);<br />
FILE *ziel;<br />
ziel = fopen(&quot;array.txt&quot;,&quot;w&quot;);<br />
for (int j = 0; j &lt; n; ++j)<br />
{<br />
values[j]=data[j];<br />
fprintf(ziel,&quot;%i&quot;,j);<br />
fprintf(ziel,&quot;%g&quot;,values[j]);</p>
<p>fprintf (ziel,&quot;\n&quot;);</p>
<p>}<br />
fclose(ziel);<br />
}<br />
getchar();<br />
return 0;<br />
}<br />
[code]</p>
<p>Bin für alle Hilfen dankbar.</p>
<p>Ben</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/252714/problem-socket-in-c-programm-hinzuzufügen</link><generator>RSS for Node</generator><lastBuildDate>Mon, 14 Sep 2026 03:19:30 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/252714.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 23 Oct 2009 12:16:22 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem Socket in c++ Programm hinzuzufügen on Fri, 23 Oct 2009 12:16:22 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich habe ein Problem, ich möchte gerne das Array Values<br />
über einen Socket an ein anderes Programm schicken.</p>
<p>Wie fange ich da an, bzw. was muss ich da machen, wo starte ich am besten?</p>
<p>Das Programm schaut so aus:<br />
[code][cpp]<br />
#include &quot;UrgCtrl.h&quot;<br />
#include &lt;cstdlib&gt;</p>
<p>using namespace qrk;<br />
using namespace std;</p>
<p>//! main<br />
int main(int argc, char *argv[])<br />
{<br />
const char device[] = &quot;COM4&quot;;<br />
//const char device[] = &quot;/dev/ttyACM0&quot;;</p>
<p>UrgCtrl urg;<br />
urg.connect(device);<br />
/* if (! urg.connect(device)) {<br />
printf(&quot;UrgCtrl::connect: %s\n&quot;, urg.what());<br />
getchar();<br />
exit(1);<br />
}*/</p>
<p>// GD ƒRƒ}ƒ“ƒh‚ÅŽw’è‚³‚ê‚½‰ñ�”‚¾‚¯ƒXƒLƒƒƒ“‚ð�s‚¢�A�o—Í‚·‚é<br />
enum { CaptureTimes = 1 };<br />
double values[725];<br />
for (int i = 0; i &lt; CaptureTimes; ++i)<br />
{<br />
long timestamp = 0;<br />
vector&lt;long&gt; data;</p>
<p>// Žæ“¾<br />
int n = urg.capture(data, &amp;timestamp);</p>
<p>// �o—Í<br />
// printf(&quot;timestamp: %ld\n&quot;, timestamp);<br />
FILE *ziel;<br />
ziel = fopen(&quot;array.txt&quot;,&quot;w&quot;);<br />
for (int j = 0; j &lt; n; ++j)<br />
{<br />
values[j]=data[j];<br />
fprintf(ziel,&quot;%i&quot;,j);<br />
fprintf(ziel,&quot;%g&quot;,values[j]);</p>
<p>fprintf (ziel,&quot;\n&quot;);</p>
<p>}<br />
fclose(ziel);<br />
}<br />
getchar();<br />
return 0;<br />
}<br />
[code]</p>
<p>Bin für alle Hilfen dankbar.</p>
<p>Ben</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1797048</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1797048</guid><dc:creator><![CDATA[benstar]]></dc:creator><pubDate>Fri, 23 Oct 2009 12:16:22 GMT</pubDate></item><item><title><![CDATA[Reply to Problem Socket in c++ Programm hinzuzufügen on Fri, 23 Oct 2009 14:34:53 GMT]]></title><description><![CDATA[<p>Schau mal in diesen Threads nach, dort werden Socket-Tutorials angeboten:</p>
<p><a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-237242-and-highlight-is-socket+tutorial.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-237242-and-highlight-is-socket+tutorial.html</a></p>
<p><a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-245210-and-start-is-0.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-245210-and-start-is-0.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1797135</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1797135</guid><dc:creator><![CDATA[Th69]]></dc:creator><pubDate>Fri, 23 Oct 2009 14:34:53 GMT</pubDate></item><item><title><![CDATA[Reply to Problem Socket in c++ Programm hinzuzufügen on Mon, 26 Oct 2009 21:13:13 GMT]]></title><description><![CDATA[<p>Kann mir jemand sagen, wo der Fehler liegt?</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;winsock.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;

int main()
{
WSADATA wsa;
struct sockaddr_in addr;
int rc;
int s;
int senden;

char text[]={&quot;Nachricht&quot;};
struct sockaddr_in {
	short int sin_family;
	unsigned short int sin_port;
	struct in_addr sin_addr;
	unsigned char pad[8];
					};

addr.sin_family = AF_INET;
addr.sin_port = htons(399);
addr.sin_addr.s_addr = inet_addr(&quot;127.0.0.1&quot;);

s = socket(AF_INET,SOCK_STREAM,0);

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

senden = send(s,text,strlen(text),0);

system(&quot;PAUSE&quot;);
return 0;
}
</code></pre>
<p>Der Socket hat immer den Fehlerwert -1. Ich verstehe es nicht ganz.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1798817</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1798817</guid><dc:creator><![CDATA[benstar1]]></dc:creator><pubDate>Mon, 26 Oct 2009 21:13:13 GMT</pubDate></item><item><title><![CDATA[Reply to Problem Socket in c++ Programm hinzuzufügen on Mon, 26 Oct 2009 22:16:22 GMT]]></title><description><![CDATA[<p><code>WSAGetLastError()</code> , ich wette, der Port ist belegt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1798837</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1798837</guid><dc:creator><![CDATA[Ad aCTa]]></dc:creator><pubDate>Mon, 26 Oct 2009 22:16:22 GMT</pubDate></item></channel></rss>