<?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[[SOCKETS] VC kennt die Funktionen nicht]]></title><description><![CDATA[<p>Hi Leute,</p>
<p>ich wollte heute mit der Socket-Programmierung anfangen, mein Server läuft auch schon, nun wollte ich einen GUI-Clienten programmieren. Jetzt steh ich vor einem ziemlich großen Problem:</p>
<p>Der Programmcode</p>
<pre><code>#include &lt;windows.h&gt;
#include &quot;resource.h&quot;

WSADATA	WSAData;
WSAStartup(MAKEWORD(2,0),&amp;WSAData);

sock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP); // socket erstellen

sockaddr_in sa;
sa.sin_family = AF_INET;
sa.sin_port = htons(1000);
sa.sin_addr.S_un.S_addr = inet_addr(&quot;192.168.0.135&quot;);

if(connect(sock,(SOCKADDR*)&amp;sa,sizeof(sa))==SOCKET_ERROR){
	MessageBox(0,&quot;Bei connect()&quot;,&quot;Socket Error&quot;,0);}

else { WSAAsyncSelect(sock,hwnd,WM_SOCKET_NOTIFY,FD_CONNECT|FD_READ|FD_CLOSE); }

#define WM_SOCKET_NOTIFY (WM_USER + 1)
WSAAsyncSelect(sock,hwnd,WM_SOCKET_NOTIFY,FD_CONNECT|FD_READ|FD_CLOSE);

BOOL CALLBACK DlgProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{
     static char szAppName[] = &quot;Socket-Client&quot; ;

	 DialogBox(hInstance,&quot;IDD_Start&quot;,NULL,DlgProc);

   MSG msg; 
 while (GetMessage (&amp;msg, NULL, 0, 0))
          {
          TranslateMessage (&amp;msg) ;
          DispatchMessage (&amp;msg) ;
          }
     return msg.wParam ;
}

BOOL CALLBACK DlgProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
	case WM_INITDIALOG:
		HWND dlgitem;
		dlgitem = GetDlgItem(hDlg,IDC_IPADRESS);
		SendMessage(dlgitem,WM_SETTEXT,0,(long)&quot;192.168.0.135&quot;);

		dlgitem = GetDlgItem(hDlg,IDC_PORT);
		SendMessage(dlgitem,WM_SETTEXT,0,(long)&quot;10000&quot;);

		return TRUE;

	case WM_COMMAND:
		switch(LOWORD(wParam))
		{
		case CMD_CANCEL:
			PostQuitMessage(0);
			break;
		case CMD_CONNECT:

			break;
		}
		break;

	case WM_DESTROY :
         PostQuitMessage (0) ;
         break;

}
return FALSE;
}
</code></pre>
<p>Die ws2_32.lib ist natürlich mitgelinkt, trotzdem meldet VC++ 6 Standard</p>
<pre><code>--------------------Configuration: clientGUI - Win32 Debug--------------------
Compiling...
haupt.cpp
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(5) : error C2501: 'WSAStartup' : missing storage-class or type specifiers
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(5) : error C2373: 'WSAStartup' : redefinition; different type modifiers
        d:\programme\microsoft visual studio\vc98\include\winsock.h(781) : see declaration of 'WSAStartup'
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(5) : error C2078: too many initializers
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(5) : error C2440: 'initializing' : cannot convert from 'struct WSAData *' to 'int'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(7) : error C2501: 'sock' : missing storage-class or type specifiers
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(10) : error C2143: syntax error : missing ';' before '.'
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(10) : error C2501: 'sa' : missing storage-class or type specifiers
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(10) : error C2371: 'sa' : redefinition; different basic types
        D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(9) : see declaration of 'sa'
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(10) : error C2143: syntax error : missing ';' before '.'
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(11) : error C2143: syntax error : missing ';' before '.'
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(11) : error C2501: 'sa' : missing storage-class or type specifiers
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(11) : error C2371: 'sa' : redefinition; different basic types
        D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(9) : see declaration of 'sa'
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(11) : error C2143: syntax error : missing ';' before '.'
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(12) : error C2143: syntax error : missing ';' before '.'
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(12) : error C2501: 'sa' : missing storage-class or type specifiers
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(12) : error C2371: 'sa' : redefinition; different basic types
        D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(9) : see declaration of 'sa'
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(12) : error C2143: syntax error : missing ';' before '.'
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(14) : error C2143: syntax error : missing ';' before 'if'
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(14) : error C2143: syntax error : missing ';' before '{'
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(14) : error C2447: missing function header (old-style formal list?)
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(17) : error C2143: syntax error : missing ';' before 'else'
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(17) : error C2143: syntax error : missing ';' before '{'
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(17) : error C2447: missing function header (old-style formal list?)
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(22) : error C2065: 'hwnd' : undeclared identifier
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(22) : error C2501: 'WSAAsyncSelect' : missing storage-class or type specifiers
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(22) : error C2373: 'WSAAsyncSelect' : redefinition; different type modifiers
        d:\programme\microsoft visual studio\vc98\include\winsock.h(824) : see declaration of 'WSAAsyncSelect'
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(22) : error C2078: too many initializers
Error executing cl.exe.

clientGUI.exe - 27 error(s), 0 warning(s)
</code></pre>
<p>Irgendetwas scheint mit den Headern oder Libs nicht zu stimmen, wenn ich die winsock2.h einbinde, kommt immer ein Neudefinitionsfehler, diese ist scheinbar schon in der windows.h integriert.</p>
<p>Hochachtungsvoll Rodney <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/topic/70997/sockets-vc-kennt-die-funktionen-nicht</link><generator>RSS for Node</generator><lastBuildDate>Thu, 09 Apr 2026 12:59:49 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/70997.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 13 Apr 2004 22:07:06 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [SOCKETS] VC kennt die Funktionen nicht on Tue, 13 Apr 2004 22:07:06 GMT]]></title><description><![CDATA[<p>Hi Leute,</p>
<p>ich wollte heute mit der Socket-Programmierung anfangen, mein Server läuft auch schon, nun wollte ich einen GUI-Clienten programmieren. Jetzt steh ich vor einem ziemlich großen Problem:</p>
<p>Der Programmcode</p>
<pre><code>#include &lt;windows.h&gt;
#include &quot;resource.h&quot;

WSADATA	WSAData;
WSAStartup(MAKEWORD(2,0),&amp;WSAData);

sock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP); // socket erstellen

sockaddr_in sa;
sa.sin_family = AF_INET;
sa.sin_port = htons(1000);
sa.sin_addr.S_un.S_addr = inet_addr(&quot;192.168.0.135&quot;);

if(connect(sock,(SOCKADDR*)&amp;sa,sizeof(sa))==SOCKET_ERROR){
	MessageBox(0,&quot;Bei connect()&quot;,&quot;Socket Error&quot;,0);}

else { WSAAsyncSelect(sock,hwnd,WM_SOCKET_NOTIFY,FD_CONNECT|FD_READ|FD_CLOSE); }

#define WM_SOCKET_NOTIFY (WM_USER + 1)
WSAAsyncSelect(sock,hwnd,WM_SOCKET_NOTIFY,FD_CONNECT|FD_READ|FD_CLOSE);

BOOL CALLBACK DlgProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{
     static char szAppName[] = &quot;Socket-Client&quot; ;

	 DialogBox(hInstance,&quot;IDD_Start&quot;,NULL,DlgProc);

   MSG msg; 
 while (GetMessage (&amp;msg, NULL, 0, 0))
          {
          TranslateMessage (&amp;msg) ;
          DispatchMessage (&amp;msg) ;
          }
     return msg.wParam ;
}

BOOL CALLBACK DlgProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
	case WM_INITDIALOG:
		HWND dlgitem;
		dlgitem = GetDlgItem(hDlg,IDC_IPADRESS);
		SendMessage(dlgitem,WM_SETTEXT,0,(long)&quot;192.168.0.135&quot;);

		dlgitem = GetDlgItem(hDlg,IDC_PORT);
		SendMessage(dlgitem,WM_SETTEXT,0,(long)&quot;10000&quot;);

		return TRUE;

	case WM_COMMAND:
		switch(LOWORD(wParam))
		{
		case CMD_CANCEL:
			PostQuitMessage(0);
			break;
		case CMD_CONNECT:

			break;
		}
		break;

	case WM_DESTROY :
         PostQuitMessage (0) ;
         break;

}
return FALSE;
}
</code></pre>
<p>Die ws2_32.lib ist natürlich mitgelinkt, trotzdem meldet VC++ 6 Standard</p>
<pre><code>--------------------Configuration: clientGUI - Win32 Debug--------------------
Compiling...
haupt.cpp
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(5) : error C2501: 'WSAStartup' : missing storage-class or type specifiers
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(5) : error C2373: 'WSAStartup' : redefinition; different type modifiers
        d:\programme\microsoft visual studio\vc98\include\winsock.h(781) : see declaration of 'WSAStartup'
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(5) : error C2078: too many initializers
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(5) : error C2440: 'initializing' : cannot convert from 'struct WSAData *' to 'int'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(7) : error C2501: 'sock' : missing storage-class or type specifiers
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(10) : error C2143: syntax error : missing ';' before '.'
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(10) : error C2501: 'sa' : missing storage-class or type specifiers
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(10) : error C2371: 'sa' : redefinition; different basic types
        D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(9) : see declaration of 'sa'
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(10) : error C2143: syntax error : missing ';' before '.'
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(11) : error C2143: syntax error : missing ';' before '.'
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(11) : error C2501: 'sa' : missing storage-class or type specifiers
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(11) : error C2371: 'sa' : redefinition; different basic types
        D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(9) : see declaration of 'sa'
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(11) : error C2143: syntax error : missing ';' before '.'
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(12) : error C2143: syntax error : missing ';' before '.'
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(12) : error C2501: 'sa' : missing storage-class or type specifiers
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(12) : error C2371: 'sa' : redefinition; different basic types
        D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(9) : see declaration of 'sa'
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(12) : error C2143: syntax error : missing ';' before '.'
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(14) : error C2143: syntax error : missing ';' before 'if'
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(14) : error C2143: syntax error : missing ';' before '{'
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(14) : error C2447: missing function header (old-style formal list?)
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(17) : error C2143: syntax error : missing ';' before 'else'
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(17) : error C2143: syntax error : missing ';' before '{'
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(17) : error C2447: missing function header (old-style formal list?)
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(22) : error C2065: 'hwnd' : undeclared identifier
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(22) : error C2501: 'WSAAsyncSelect' : missing storage-class or type specifiers
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(22) : error C2373: 'WSAAsyncSelect' : redefinition; different type modifiers
        d:\programme\microsoft visual studio\vc98\include\winsock.h(824) : see declaration of 'WSAAsyncSelect'
D:\Programmierung\Geproggtes\SOCKETS\clientGUI\haupt.cpp(22) : error C2078: too many initializers
Error executing cl.exe.

clientGUI.exe - 27 error(s), 0 warning(s)
</code></pre>
<p>Irgendetwas scheint mit den Headern oder Libs nicht zu stimmen, wenn ich die winsock2.h einbinde, kommt immer ein Neudefinitionsfehler, diese ist scheinbar schon in der windows.h integriert.</p>
<p>Hochachtungsvoll Rodney <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/500927</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/500927</guid><dc:creator><![CDATA[Rodney]]></dc:creator><pubDate>Tue, 13 Apr 2004 22:07:06 GMT</pubDate></item><item><title><![CDATA[Reply to [SOCKETS] VC kennt die Funktionen nicht on Tue, 13 Apr 2004 23:13:00 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>du solltest nicht Quellcode wild in die Landschaft des VC-Editors platzieren <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="🙂"
    /> , der ganze Kram, der angemeckert wird, muß natürlich in einer Funktion stehen!! Also ab in WinMain damit (bis auf das #define), und dann sollten einige, wenn nicht alle Fehler verschwinden.</p>
<p>MfG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/500965</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/500965</guid><dc:creator><![CDATA[Probe-Nutzer]]></dc:creator><pubDate>Tue, 13 Apr 2004 23:13:00 GMT</pubDate></item><item><title><![CDATA[Reply to [SOCKETS] VC kennt die Funktionen nicht on Wed, 14 Apr 2004 11:26:20 GMT]]></title><description><![CDATA[<p>Probe-Nutzer schrieb:</p>
<blockquote>
<p>Hallo,</p>
<p>du solltest nicht Quellcode wild in die Landschaft des VC-Editors platzieren <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="🙂"
    /> , der ganze Kram, der angemeckert wird, muß natürlich in einer Funktion stehen!! Also ab in WinMain damit (bis auf das #define), und dann sollten einige, wenn nicht alle Fehler verschwinden.</p>
<p>MfG</p>
</blockquote>
<p>asche über mein haupt... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /><br />
THX <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/501241</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/501241</guid><dc:creator><![CDATA[Rodney]]></dc:creator><pubDate>Wed, 14 Apr 2004 11:26:20 GMT</pubDate></item></channel></rss>