<?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[Übergabe an Thread]]></title><description><![CDATA[<p>Hallo Allerseits,</p>
<p>ich habe folgene Frage und hoffe ihr könnt mir da helfen:</p>
<p>Ich habe in der Hauptfunktion ein socket und SOCKADDR_IN struct deklariert und letzteres auch initialisiert.</p>
<p>das connecten möchte ich ihn einem thread machen.</p>
<p>beide structs habe ich in ein struct gepackt und will dieses an den Thread übergeben.</p>
<p>Und jetzt kommts zur eigentlichen Frage:</p>
<p>Reicht es wenn ich dem Thread mein Struct übergebe oder muss ich dieses Struct jetzt auch an die Funktion übergeben?</p>
<p>Wenn letzteres zutrifft: Wie soll ich das machen? (hab das Gefühl das das GANZ einfach is lol aba steh grad auf der Leitung)</p>
<p>Denn ausserhalb der Hauptfunktion sind diese structs ja nicht gültig.<br />
Wenn ichs als Parameter übergeben soll soll ich dann reinschreiben</p>
<p>Funktionsname(SOCKET param_1,SOCKADDR_IN param2) (bei der Deklaration mein ich)?</p>
<p>MFG</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/169416/übergabe-an-thread</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Jul 2026 18:43:57 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/169416.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 05 Jan 2007 06:09:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Übergabe an Thread on Fri, 05 Jan 2007 06:09:00 GMT]]></title><description><![CDATA[<p>Hallo Allerseits,</p>
<p>ich habe folgene Frage und hoffe ihr könnt mir da helfen:</p>
<p>Ich habe in der Hauptfunktion ein socket und SOCKADDR_IN struct deklariert und letzteres auch initialisiert.</p>
<p>das connecten möchte ich ihn einem thread machen.</p>
<p>beide structs habe ich in ein struct gepackt und will dieses an den Thread übergeben.</p>
<p>Und jetzt kommts zur eigentlichen Frage:</p>
<p>Reicht es wenn ich dem Thread mein Struct übergebe oder muss ich dieses Struct jetzt auch an die Funktion übergeben?</p>
<p>Wenn letzteres zutrifft: Wie soll ich das machen? (hab das Gefühl das das GANZ einfach is lol aba steh grad auf der Leitung)</p>
<p>Denn ausserhalb der Hauptfunktion sind diese structs ja nicht gültig.<br />
Wenn ichs als Parameter übergeben soll soll ich dann reinschreiben</p>
<p>Funktionsname(SOCKET param_1,SOCKADDR_IN param2) (bei der Deklaration mein ich)?</p>
<p>MFG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1203234</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1203234</guid><dc:creator><![CDATA[Muhi89]]></dc:creator><pubDate>Fri, 05 Jan 2007 06:09:00 GMT</pubDate></item><item><title><![CDATA[Reply to Übergabe an Thread on Fri, 05 Jan 2007 06:51:20 GMT]]></title><description><![CDATA[<p>Muhi89 schrieb:</p>
<blockquote>
<p>Reicht es wenn ich dem Thread mein Struct übergebe oder muss ich dieses Struct jetzt auch an die Funktion übergeben?</p>
</blockquote>
<p>Welche Funktion hast Du denn noch???<br />
Verstehe ich nicht ganz...</p>
<p>PS: Du musst darauf achten, dass der Übergebene Zeiger garantiert gültig ist, wenn den Thread darauf zugreift!<br />
Also niemals sowas machen:</p>
<pre><code class="language-cpp">void StartThread()
{
  tThreadData data;
  data. = ...;  // Fülle die data-Struct
  CreateThread(....., &amp;data, ...);
  return;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1203246</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1203246</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Fri, 05 Jan 2007 06:51:20 GMT</pubDate></item><item><title><![CDATA[Reply to Übergabe an Thread on Fri, 05 Jan 2007 11:35:59 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ich versteh dich leider auch nicht ganz,</p>
<p>also mein code sieht in etwa so aus</p>
<p>includes</p>
<p>deklariere WSA STARTUP-Funktion</p>
<p>WinMain(parameter)</p>
<p>{</p>
<p>WAS-STARTUP<br />
//deklariere &quot;Objekte&quot; des Typs SOCKET und SOCKADDR_IN;<br />
//Fülle SOCKDDR_IN mit allen nötigen Daten</p>
<p>neue Struktur deklarieren und beide structs reinpacken</p>
<p>CreateThread(Paramter) //startet MeinThread als Thread</p>
<p>//weiterer Code<br />
return 0;</p>
<p>}</p>
<p>MeinThread(Sockets param1)</p>
<p>{<br />
connect(parameter)</p>
<p>return 0;<br />
}</p>
<p>steh da voll auf der Leitung.</p>
<p>Alles was ich will ist, dass ich die´zwei Strukturen die für die Verbindung notwendig sind deklariere etc, und dann in einem Thread versuche zu connecten.</p>
<p>PS: Wieso funzt das nicht? data is wird ja gefüllt <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>
]]></description><link>https://www.c-plusplus.net/forum/post/1203456</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1203456</guid><dc:creator><![CDATA[Muhi89]]></dc:creator><pubDate>Fri, 05 Jan 2007 11:35:59 GMT</pubDate></item><item><title><![CDATA[Reply to Übergabe an Thread on Fri, 05 Jan 2007 12:22:09 GMT]]></title><description><![CDATA[<p>wie wäre es einfach mit a bissi code? anstatt diesen falschen pseudocode <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="⚠"
    /><br />
zb: konvention der thread funktion stimmt nicht.<br />
ps: schön und gut wenn sie gefüllt sind aber sind diese auch zum zeitpunkt der dereferenzierung auch gültig?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1203490</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1203490</guid><dc:creator><![CDATA[miller_m]]></dc:creator><pubDate>Fri, 05 Jan 2007 12:22:09 GMT</pubDate></item><item><title><![CDATA[Reply to Übergabe an Thread on Fri, 05 Jan 2007 17:48:09 GMT]]></title><description><![CDATA[<p>Ich würde sagen, du müsstest im Haupt-Thread mit WaitForSingleObject auf deinen Connect-Thread warten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1203822</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1203822</guid><dc:creator><![CDATA[Dr. C++]]></dc:creator><pubDate>Fri, 05 Jan 2007 17:48:09 GMT</pubDate></item><item><title><![CDATA[Reply to Übergabe an Thread on Fri, 05 Jan 2007 17:54:54 GMT]]></title><description><![CDATA[<p>Dr. C++ schrieb:</p>
<blockquote>
<p>Ich würde sagen, du müsstest im Haupt-Thread mit WaitForSingleObject auf deinen Connect-Thread warten.</p>
</blockquote>
<p>Warum dann überhaupt die Mühe mit dem Thread!?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1203831</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1203831</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Fri, 05 Jan 2007 17:54:54 GMT</pubDate></item><item><title><![CDATA[Reply to Übergabe an Thread on Sat, 06 Jan 2007 12:36:46 GMT]]></title><description><![CDATA[<p>Jochen Kalmbach schrieb:</p>
<blockquote>
<p>Dr. C++ schrieb:</p>
<blockquote>
<p>Ich würde sagen, du müsstest im Haupt-Thread mit WaitForSingleObject auf deinen Connect-Thread warten.</p>
</blockquote>
<p>Warum dann überhaupt die Mühe mit dem Thread!?</p>
</blockquote>
<p>Hab ich mich auch gefragt, aber den Code, den er gepostet hat, ist ja nur Pseudocode. Es kann ja sein, dass er im Hauptthread noch was anderes macht.</p>
<p>@Muhi89: Wenn der Hauptthread ausläuft wird die Anwendung beendet und mit ihr alle laufenden Threads.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1204221</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1204221</guid><dc:creator><![CDATA[Dr. C++]]></dc:creator><pubDate>Sat, 06 Jan 2007 12:36:46 GMT</pubDate></item><item><title><![CDATA[Reply to Übergabe an Thread on Sat, 06 Jan 2007 13:07:03 GMT]]></title><description><![CDATA[<p>Dr. C++ schrieb:</p>
<blockquote>
<p>@Muhi89: Wenn der Hauptthread ausläuft wird die Anwendung beendet und mit ihr alle laufenden Threads.</p>
</blockquote>
<p>Zumindest wenn man dir CRT verwendet, da diese ExitProcess aufruft...<br />
Siehe auch: When does a program terminate?<br />
<a href="http://blog.kalmbachnet.de/?postid=65" rel="nofollow">http://blog.kalmbachnet.de/?postid=65</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1204238</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1204238</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sat, 06 Jan 2007 13:07:03 GMT</pubDate></item><item><title><![CDATA[Reply to Übergabe an Thread on Sat, 06 Jan 2007 13:14:49 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ja ich mache einen extra Thread damit ich während des Verbindungsversuches was checken kann und verarbeiten kann.</p>
<p>MFG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1204246</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1204246</guid><dc:creator><![CDATA[Muhi89]]></dc:creator><pubDate>Sat, 06 Jan 2007 13:14:49 GMT</pubDate></item><item><title><![CDATA[Reply to Übergabe an Thread on Sat, 06 Jan 2007 15:31:14 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#pragma comment( lib, &quot;ws2_32.lib&quot; )
#include &lt;winsock2.h&gt;
#include &lt;winsock.h&gt;
#include &lt;stdio.h&gt; 
#include &lt;time.h&gt; 
#include &lt;windows.h&gt;
#include &lt;stdio.h&gt;

int Connection(void);

int WINAPI WinMain( HINSTANCE hInstance,
                                   HINSTANCE hInstance_2,
                                   LPSTR CmdLine, int Show )
{

int id=1;

SOCKET ProtoClient;
SOCKADDR_IN ProtoAddress;
ProtoClient=socket(AF_INET,SOCK_STREAM,0);
memset(&amp;ProtoAddress,0,sizeof(SOCKADDR_IN));

ProtoAddress.sin_family=AF_INET;
ProtoAddress.sin_port=htons(12345);
ProtoAddress.sin_addr.s_addr=ADDR_ANY;

struct Sockets

{
SOCKET Client;
SOCKADDR_IN Address;
}

structname;

structname.Client=ProtoClient;
structname.Address=ProtoAddress;

//Diese Daten möchte ich jetzt an den Thread übergeben

handle=CreateThread(0,0,(LPTHREAD_START_ROUTINE)Connection,(LPVOID)&amp;structname ,0,&amp;id);	

return 0;

}

int Connection(void)

{

return 0;
}
</code></pre>
<p>Da ich ja auf der Leitung stehe kann ich nur mal diesen Code posten.</p>
<p>Mein Problem:</p>
<p>Reicht es wenn ich das struct per CreateThread übergebe oder muss ich es auch der Funktion übergeben?</p>
<p>MFG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1204382</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1204382</guid><dc:creator><![CDATA[Muhi89]]></dc:creator><pubDate>Sat, 06 Jan 2007 15:31:14 GMT</pubDate></item><item><title><![CDATA[Reply to Übergabe an Thread on Sat, 06 Jan 2007 15:46:33 GMT]]></title><description><![CDATA[<p>Wenn man casten muss, dann ist das immer ein schlechtes Zeichen!<br />
Deshalb: Lass das casten weg und mach:</p>
<pre><code class="language-cpp">DWORD WINAPI Connection(void);
</code></pre>
<p>und</p>
<pre><code class="language-cpp">handle=CreateThread(0,0, Connection,(LPVOID)&amp;structname ,0,&amp;id);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1204394</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1204394</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sat, 06 Jan 2007 15:46:33 GMT</pubDate></item><item><title><![CDATA[Reply to Übergabe an Thread on Sat, 06 Jan 2007 15:50:49 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>danke für die Antwort,</p>
<p>was bewirkt &quot;DWORD WINAPI&quot;? (nicht schlagen gg)</p>
<p>mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1204400</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1204400</guid><dc:creator><![CDATA[Muhi89]]></dc:creator><pubDate>Sat, 06 Jan 2007 15:50:49 GMT</pubDate></item><item><title><![CDATA[Reply to Übergabe an Thread on Sat, 06 Jan 2007 16:54:44 GMT]]></title><description><![CDATA[<p>DWORD ist der Rückgabetyp</p>
<pre><code class="language-cpp">typedef unsigned long DWORD;
</code></pre>
<p>und WINAPI kümmert sich um die Calling-Convention.<br />
(also was die Parameter und so angeht, aber das geht dann schon in den Bereich Assembler)</p>
<pre><code class="language-cpp">#define WINAPI __stdcall
// Standard ist __cdecl
// es gibt auch noch __fastcall
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1204447</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1204447</guid><dc:creator><![CDATA[DrakoXP]]></dc:creator><pubDate>Sat, 06 Jan 2007 16:54:44 GMT</pubDate></item><item><title><![CDATA[Reply to Übergabe an Thread on Sat, 06 Jan 2007 16:57:46 GMT]]></title><description><![CDATA[<p>Danke!</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/5675">@Jochen</a>:</p>
<p>Thx, aba das war ja nicht der Fehler (also wegen des Problems) oder?</p>
<p>MFG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1204450</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1204450</guid><dc:creator><![CDATA[Muhi89]]></dc:creator><pubDate>Sat, 06 Jan 2007 16:57:46 GMT</pubDate></item><item><title><![CDATA[Reply to Übergabe an Thread on Sat, 06 Jan 2007 17:11:09 GMT]]></title><description><![CDATA[<p>Was für ein Fehler? und was für ein Problem?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1204462</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1204462</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sat, 06 Jan 2007 17:11:09 GMT</pubDate></item><item><title><![CDATA[Reply to Übergabe an Thread on Sat, 06 Jan 2007 17:16:48 GMT]]></title><description><![CDATA[<p>Vielleicht könntest du erstmal sagen, WAS nicht funktioniert. Nimmt der Compiler den Code nicht(könnte ich mir vorstellen) oder passiert im Programm einfach nix?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1204468</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1204468</guid><dc:creator><![CDATA[Dr. C++]]></dc:creator><pubDate>Sat, 06 Jan 2007 17:16:48 GMT</pubDate></item><item><title><![CDATA[Reply to Übergabe an Thread on Sat, 06 Jan 2007 17:48:50 GMT]]></title><description><![CDATA[<p>Wenn ich Dir mal was (fast) ganz anderes vorschlagen <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 />
Warum nimmst Du nicht die WinInet-API, da ist schon alles in Threads gepackt! Da bekommste dann ne Nachricht, wenn was spezielles passiert (Daten angekommen, Connect erfolgreich, usw. ...).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1204517</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1204517</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Sat, 06 Jan 2007 17:48:50 GMT</pubDate></item><item><title><![CDATA[Reply to Übergabe an Thread on Sat, 06 Jan 2007 17:59:55 GMT]]></title><description><![CDATA[<p>Das Problem ist,dass ich nicht weiss WAS ich machen soll/muss.</p>
<p>Ich will einen eigenen Thread nur fürs connecten machen.</p>
<p>Muss ich jetzt das Struct dass die beiden anderen Structs beinhaltet NUR an den Thread übergeben ODER auch an die Funktion übergeben.</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/12048">@Codefinder</a>:</p>
<p>Hmm Thx das schau ich mir gleich mal an.</p>
<p>Wär trotzdem froh wenn ich wüsste wie ichs ohne WinInet API mach</p>
<p>Lg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1204533</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1204533</guid><dc:creator><![CDATA[Muhi89]]></dc:creator><pubDate>Sat, 06 Jan 2007 17:59:55 GMT</pubDate></item><item><title><![CDATA[Reply to Übergabe an Thread on Sat, 06 Jan 2007 18:11:22 GMT]]></title><description><![CDATA[<p>Wenn du den Thread nur fürs connecten benutzen willst: warum initialisiert du die ganzen structs nicht einfach in deinem Thread und lässt deine WinMain damit in Ruhe?!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1204548</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1204548</guid><dc:creator><![CDATA[Dr. C++]]></dc:creator><pubDate>Sat, 06 Jan 2007 18:11:22 GMT</pubDate></item><item><title><![CDATA[Reply to Übergabe an Thread on Sat, 06 Jan 2007 18:22:19 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#pragma comment( lib, &quot;ws2_32.lib&quot; ) 
#include &lt;winsock2.h&gt; 
#include &lt;winsock.h&gt; 
#include &lt;stdio.h&gt; 
#include &lt;time.h&gt; 
#include &lt;windows.h&gt; 
#include &lt;stdio.h&gt; 

DWORD WINAPI Connection(void) 

{ 
SOCKET ProtoClient; 
SOCKADDR_IN ProtoAddress; 
ProtoClient=socket(AF_INET,SOCK_STREAM,0); 
memset(&amp;ProtoAddress,0,sizeof(SOCKADDR_IN)); 

ProtoAddress.sin_family=AF_INET; 
ProtoAddress.sin_port=htons(12345); 
ProtoAddress.sin_addr.s_addr=ADDR_ANY; 

struct Sockets 

{ 
SOCKET Client; 
SOCKADDR_IN Address; 
} structname; 

structname.Client=ProtoClient; 
structname.Address=ProtoAddress; 

connect(structname.Client,(SOCKADDR*)&amp;structname.Address,sizeof(SOCKADDR));

return 0; 
} 

int WINAPI WinMain( HINSTANCE hInstance, 
                                   HINSTANCE hInstance_2, 
                                   LPSTR CmdLine, int Show ) 
{ 

unsigned long int id=1; 

//Diese Daten möchte ich jetzt an den Thread übergeben 

HANDLE handle;

handle=CreateThread(0,0,(LPTHREAD_START_ROUTINE)Connection,(LPVOID)&amp;structname ,0,&amp;id);    

return 0; 

}
</code></pre>
<p>k nur jetzt hab ich (auch wenns sicher n triviales Problem ist) das Problem, dass structname nur in Connection gültig ist.</p>
<p>Lg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1204557</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1204557</guid><dc:creator><![CDATA[Muhi89]]></dc:creator><pubDate>Sat, 06 Jan 2007 18:22:19 GMT</pubDate></item><item><title><![CDATA[Reply to Übergabe an Thread on Sat, 06 Jan 2007 18:23:27 GMT]]></title><description><![CDATA[<p>Global deklarieren?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1204560</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1204560</guid><dc:creator><![CDATA[Dr. C++]]></dc:creator><pubDate>Sat, 06 Jan 2007 18:23:27 GMT</pubDate></item><item><title><![CDATA[Reply to Übergabe an Thread on Sat, 06 Jan 2007 18:25:16 GMT]]></title><description><![CDATA[<p>Ich glaube Du musst Dir zuerst mal selber im klaren werden was Du willst, bevor Du hier weiter fragen stellen kannst...<br />
In Deinem Thread ist überhaupt nichts klar. Weder warum Du einen Thread machen willst, noch was Du mit der Socket-Verbindung überhaupt anstellen willst...<br />
Also: Erklär zuerst mal was Du machen willst, bevor Dir irgendwer überhaupt sinnvoll weiterhelfen kann...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1204562</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1204562</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sat, 06 Jan 2007 18:25:16 GMT</pubDate></item><item><title><![CDATA[Reply to Übergabe an Thread on Sat, 06 Jan 2007 20:08:01 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>rofl</p>
<p>also erstens weiss ich GENAU was ich will,<br />
ich habe es auch schon genau drei Mal beschrieben.</p>
<p>egal, danke für eure Antworten, ich probiers einfach so lang weiter bis es irgendwann klappt.</p>
<p>Alles was ich jetzt will ist dass die structs auch in der anderen Funktion bekannt sind.<br />
Global deklarieren funzt nicht:I:\Programme\PellesC\Projects\Threading\threading-2.c(20): warning #2099: Missing type specifier.<br />
I:\Programme\PellesC\Projects\Threading\threading-2.c(20): error #2120: Redeclaration of 'ProtoClient' previously declared at I:\Programme\PellesC\Projects\Threading\threading-2.c(17): found 'int' expected 'unsigned int'.<br />
I:\Programme\PellesC\Projects\Threading\threading-2.c(20): error #2069: Initializer must be constant.<br />
I:\Programme\PellesC\Projects\Threading\threading-2.c(22): warning #2099: Missing type specifier.<br />
I:\Programme\PellesC\Projects\Threading\threading-2.c(22): error #2001: Syntax error: found '&amp;' - expecting ')'.<br />
I:\Programme\PellesC\Projects\Threading\threading-2.c(22): error #2120: Redeclaration of 'memset' previously declared at I:\Programme\PellesC\Include\string.h(22): found 'int __cdecl function' expected 'void * __cdecl function(void *, int, unsigned int)'.<br />
I:\Programme\PellesC\Projects\Threading\threading-2.c(22): error #2001: Syntax error: found ')' - expecting ';'.<br />
I:\Programme\PellesC\Projects\Threading\threading-2.c(24): warning #2099: Missing type specifier.<br />
I:\Programme\PellesC\Projects\Threading\threading-2.c(24): error #2120: Redeclaration of 'ProtoAddress' previously declared at I:\Programme\PellesC\Projects\Threading\threading-2.c(18): found 'int' expected 'struct sockaddr_in'.<br />
I:\Programme\PellesC\Projects\Threading\threading-2.c(24): error #2001: Syntax error: found '.' - expecting ';'.<br />
I:\Programme\PellesC\Projects\Threading\threading-2.c(24): warning #2099: Missing type specifier.<br />
I:\Programme\PellesC\Projects\Threading\threading-2.c(25): warning #2099: Missing type specifier.<br />
I:\Programme\PellesC\Projects\Threading\threading-2.c(25): error #2001: Syntax error: found '.' - expecting ';'.<br />
I:\Programme\PellesC\Projects\Threading\threading-2.c(25): warning #2099: Missing type specifier.<br />
I:\Programme\PellesC\Projects\Threading\threading-2.c(25): error #2069: Initializer must be constant.<br />
I:\Programme\PellesC\Projects\Threading\threading-2.c(26): warning #2099: Missing type specifier.<br />
I:\Programme\PellesC\Projects\Threading\threading-2.c(26): error #2001: Syntax error: found '.' - expecting ';'.<br />
I:\Programme\PellesC\Projects\Threading\threading-2.c(26): warning #2099: Missing type specifier.<br />
I:\Programme\PellesC\Projects\Threading\threading-2.c(26): error #2001: Syntax error: found '.' - expecting ';'.<br />
I:\Programme\PellesC\Projects\Threading\threading-2.c(26): warning #2099: Missing type specifier.<br />
I:\Programme\PellesC\Projects\Threading\threading-2.c(26): error #2001: Syntax error: found '.' - expecting ';'.<br />
I:\Programme\PellesC\Projects\Threading\threading-2.c(26): warning #2099: Missing type specifier.<br />
I:\Programme\PellesC\Projects\Threading\threading-2.c(35): warning #2099: Missing type specifier.<br />
I:\Programme\PellesC\Projects\Threading\threading-2.c(35): error #2120: Redeclaration of 'structname' previously declared at I:\Programme\PellesC\Projects\Threading\threading-2.c(33): found 'int' expected 'struct Sockets'.<br />
I:\Programme\PellesC\Projects\Threading\threading-2.c(35): error #2001: Syntax error: found '.' - expecting ';'.<br />
I:\Programme\PellesC\Projects\Threading\threading-2.c(35): warning #2099: Missing type specifier.<br />
I:\Programme\PellesC\Projects\Threading\threading-2.c(35): error #2069: Initializer must be constant.<br />
I:\Programme\PellesC\Projects\Threading\threading-2.c(36): warning #2099: Missing type specifier.<br />
I:\Programme\PellesC\Projects\Threading\threading-2.c(36): error #2001: Syntax error: found '.' - expecting ';'.<br />
I:\Programme\PellesC\Projects\Threading\threading-2.c(36): warning #2099: Missing type specifier.<br />
I:\Programme\PellesC\Projects\Threading\threading-2.c(36): error #2069: Initializer must be constant.<br />
I:\Programme\PellesC\Projects\Threading\threading-2.c(64): error #2113: Left operand of . has incompatible type 'int'.<br />
I:\Programme\PellesC\Projects\Threading\threading-2.c(64): error #2113: Left operand of . has incompatible type 'int'.<br />
*** Error code: 1 ***<br />
Done.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1204643</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1204643</guid><dc:creator><![CDATA[Muhi89]]></dc:creator><pubDate>Sat, 06 Jan 2007 20:08:01 GMT</pubDate></item><item><title><![CDATA[Reply to Übergabe an Thread on Sat, 06 Jan 2007 20:18:29 GMT]]></title><description><![CDATA[<p>Versuchs mal damit:</p>
<pre><code class="language-cpp">#pragma comment( lib, &quot;wsock32.lib&quot; )

#include &lt;stdio.h&gt;
#include &lt;time.h&gt;
#include &lt;windows.h&gt;

typedef struct _Sockets
{
SOCKET Client;
SOCKADDR_IN Address;
} Sockets;

Sockets structname;

DWORD WINAPI Connection(void)
{
    SOCKET ProtoClient;
    SOCKADDR_IN ProtoAddress;
    ProtoClient = socket(AF_INET,SOCK_STREAM,0);
    memset(&amp;ProtoAddress,0,sizeof(SOCKADDR_IN));

    ProtoAddress.sin_family = AF_INET;
    ProtoAddress.sin_port = htons(12345);
    ProtoAddress.sin_addr.s_addr = ADDR_ANY;

    structname.Client = ProtoClient;
    structname.Address = ProtoAddress;

    connect(structname.Client, (SOCKADDR*)&amp;structname.Address, sizeof(SOCKADDR));

    return 0;
}

int WINAPI WinMain( HINSTANCE hInstance,
                                   HINSTANCE hInstance_2,
                                   LPSTR CmdLine, int Show )
{
    DWORD id;
    HANDLE handle = CreateThread(0, 0, &amp;Connection, 0, 0, &amp;id);    

    return 0;
}
</code></pre>
<p>Müsste funzen(nicht getestet).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1204651</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1204651</guid><dc:creator><![CDATA[Dr. C++]]></dc:creator><pubDate>Sat, 06 Jan 2007 20:18:29 GMT</pubDate></item><item><title><![CDATA[Reply to Übergabe an Thread on Sat, 06 Jan 2007 20:18:31 GMT]]></title><description><![CDATA[<p>Ich will doch NUR wissen LOL ob ich wenn ich einen Thread starte der eine Funktion abarbeitet, es reicht nur dem Thread die vars zu geben oder auch der Fubnktion die die vars braucht.</p>
<p>Mehr will ich ned wissen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1204652</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1204652</guid><dc:creator><![CDATA[Muhi89]]></dc:creator><pubDate>Sat, 06 Jan 2007 20:18:31 GMT</pubDate></item><item><title><![CDATA[Reply to Übergabe an Thread on Sat, 06 Jan 2007 20:22:24 GMT]]></title><description><![CDATA[<p>ah 2 secs nach dir gepostet gg.</p>
<p>Vielen Dank ich probiers gleich mal</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1204655</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1204655</guid><dc:creator><![CDATA[Muhi89]]></dc:creator><pubDate>Sat, 06 Jan 2007 20:22:24 GMT</pubDate></item></channel></rss>