<?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[Konstruktor Socket]]></title><description><![CDATA[<p>Hallo zusammen. Ich habe ein Problem mit meinem Konstruktor beim Bau eines Sockets.<br />
Ich habe folgende Header Datei:</p>
<pre><code>class dgSocket
{

public:

	/// the states a socket can be in.
	enum sockstate_type { LISTENING, ACCEPTED, CONNECTED, INVALID };

	/// default constructor
	dgSocket();

	// get information about the socket state
	bool IsConnected() { return (m_SocketState == CONNECTED ||  m_SocketState == ACCEPTED); };
	bool IsListening() { return (m_SocketState == LISTENING); };

	/// constructor for a client
	dgSocket(const char* pIpAddress, int nPort);

	/// constructor for a server
	dgSocket(int nPort, bool bLocal = false);

	/// destructor
	virtual ~dgSocket();
</code></pre>
<p>USW.<br />
Und ich will jetz einfach des DgSocket für den Client aufrufen. Irgendwie steh ich total auf dem Schlauch. Mein Client-Code:</p>
<pre><code>#include &quot;stdafx.h&quot;
#include &lt;stdio.h&gt;
#include &lt;iostream&gt;
#include &quot;dgSocket.h&quot;
#include &quot;Client.h&quot;

int main( int argc, char* argv[]){

   dgSocket m_dgSocket;
   m_dgSocket.dgSocket(127.0.0.1, 3011);

   cvvWaitKey(0);
	return 0;
}
</code></pre>
<p>Irgendwei verstehe ich auch nicht ganz, ob ich jetzt dem Client eine IP oder einen Port mitgeben muss.<br />
Ihr könnt mir doch bestimmt helfen.</p>
<p>Vielen Dank<br />
EvA</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/132340/konstruktor-socket</link><generator>RSS for Node</generator><lastBuildDate>Thu, 27 Aug 2026 14:10:35 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/132340.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 10 Jan 2006 08:01:05 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Konstruktor Socket on Tue, 10 Jan 2006 08:01:05 GMT]]></title><description><![CDATA[<p>Hallo zusammen. Ich habe ein Problem mit meinem Konstruktor beim Bau eines Sockets.<br />
Ich habe folgende Header Datei:</p>
<pre><code>class dgSocket
{

public:

	/// the states a socket can be in.
	enum sockstate_type { LISTENING, ACCEPTED, CONNECTED, INVALID };

	/// default constructor
	dgSocket();

	// get information about the socket state
	bool IsConnected() { return (m_SocketState == CONNECTED ||  m_SocketState == ACCEPTED); };
	bool IsListening() { return (m_SocketState == LISTENING); };

	/// constructor for a client
	dgSocket(const char* pIpAddress, int nPort);

	/// constructor for a server
	dgSocket(int nPort, bool bLocal = false);

	/// destructor
	virtual ~dgSocket();
</code></pre>
<p>USW.<br />
Und ich will jetz einfach des DgSocket für den Client aufrufen. Irgendwie steh ich total auf dem Schlauch. Mein Client-Code:</p>
<pre><code>#include &quot;stdafx.h&quot;
#include &lt;stdio.h&gt;
#include &lt;iostream&gt;
#include &quot;dgSocket.h&quot;
#include &quot;Client.h&quot;

int main( int argc, char* argv[]){

   dgSocket m_dgSocket;
   m_dgSocket.dgSocket(127.0.0.1, 3011);

   cvvWaitKey(0);
	return 0;
}
</code></pre>
<p>Irgendwei verstehe ich auch nicht ganz, ob ich jetzt dem Client eine IP oder einen Port mitgeben muss.<br />
Ihr könnt mir doch bestimmt helfen.</p>
<p>Vielen Dank<br />
EvA</p>
]]></description><link>https://www.c-plusplus.net/forum/post/962380</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/962380</guid><dc:creator><![CDATA[kalua31]]></dc:creator><pubDate>Tue, 10 Jan 2006 08:01:05 GMT</pubDate></item><item><title><![CDATA[Reply to Konstruktor Socket on Tue, 10 Jan 2006 08:09:19 GMT]]></title><description><![CDATA[<p>Du mußt die Konstruktor-Parameter direkt bei der Variablen-Definition angeben:</p>
<pre><code class="language-cpp">int main( int argc, char* argv[])
{
  dgSocket m_dgSocket(&quot;127.0.0.1&quot;, 3011);

  if(!m_dgSocket.IsConnected())
    cout&lt;&lt;&quot;Fehler bei Verbindung&quot;&lt;&lt;endl;
  else
    //Verbindung steht -&gt; tausche Daten aus
}
</code></pre>
<p>PS: Und ein char* Literal solltest du in Anführungszeichen setzen <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/962383</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/962383</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 10 Jan 2006 08:09:19 GMT</pubDate></item><item><title><![CDATA[Reply to Konstruktor Socket on Tue, 10 Jan 2006 08:28:40 GMT]]></title><description><![CDATA[<p>Vielen vielen Dank, es funktioniert !!</p>
<p>Und wie mache ich das jetzt auf Server-Seite? Etwa so?</p>
<pre><code class="language-cpp">int main( int argc, char* argv[])
{
  dgSocket m_dgSocket(3011,true);

  if(!m_dgSocket.Listening())
    cout&lt;&lt;&quot;Fehler bei Server&quot;&lt;&lt;endl;
  else
    //accept

   cvvWaitKey(0);
	return 0;
}
</code></pre>
<p>Eigentlich bekommt der Server doch aber keinen Port übergeben, oder?</p>
<p>Vielen Dank<br />
Eva</p>
]]></description><link>https://www.c-plusplus.net/forum/post/962398</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/962398</guid><dc:creator><![CDATA[kalua31]]></dc:creator><pubDate>Tue, 10 Jan 2006 08:28:40 GMT</pubDate></item><item><title><![CDATA[Reply to Konstruktor Socket on Tue, 10 Jan 2006 08:32:39 GMT]]></title><description><![CDATA[<p>Ja, das würde so funktionieren (wenn deine Funktionen das richtige machen).</p>
<blockquote>
<p>Eigentlich bekommt der Server doch aber keinen Port übergeben, oder?</p>
</blockquote>
<p>Doch, bekommt er - woher soll er sonst wissen, was er abhören soll? (und außerdem verlangt der entsprechende Ctor eine Portnummer als Parameter)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/962402</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/962402</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 10 Jan 2006 08:32:39 GMT</pubDate></item><item><title><![CDATA[Reply to Konstruktor Socket on Tue, 10 Jan 2006 08:52:17 GMT]]></title><description><![CDATA[<p>Super, der Code ist Korrekt. Vielen Dank. Ich habs verstanden.<br />
Allerdings kommen jetzt auf Server als auch auf Client Seite 2 Linker Fehler:</p>
<blockquote>
<p>Client.obj : error LNK2019: unresolved external symbol &quot;public: virtual __thiscall dgSocket::~dgSocket(void)&quot; (??1dgSocket@@UAE@XZ) referenced in function _main<br />
Client.obj : error LNK2019: unresolved external symbol &quot;public: __thiscall dgSocket::dgSocket(char const *,int)&quot; (??0dgSocket@@QAE@PBDH@Z) referenced in function _main<br />
Debug/Client.exe : fatal error LNK1120: 2 unresolved externals</p>
</blockquote>
<p>Ich habe allerdings meine Libs ordentlich verlinkt. Was kann mir denn da fehlen?</p>
<p>Vielen Dank<br />
Eva</p>
]]></description><link>https://www.c-plusplus.net/forum/post/962420</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/962420</guid><dc:creator><![CDATA[kalua31]]></dc:creator><pubDate>Tue, 10 Jan 2006 08:52:17 GMT</pubDate></item><item><title><![CDATA[Reply to Konstruktor Socket on Tue, 10 Jan 2006 09:14:07 GMT]]></title><description><![CDATA[<p>Hast du auch eine &quot;dgSocket.cpp&quot;, in der die Quelltexte zu deinen Konstruktoren und zum Destruktor enthalten sind? Wenn nein, solltest du sie schleunigst schreiben <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/962434</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/962434</guid><dc:creator><![CDATA[CStoll (off)]]></dc:creator><pubDate>Tue, 10 Jan 2006 09:14:07 GMT</pubDate></item></channel></rss>