<?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 mit Socket]]></title><description><![CDATA[<p>Hi, hab das PRoblem, dass das FD_CONNECT evnet und das FD_READ event nicht funktionieren! (Beim Clienten)</p>
<p>SERVER:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;winsock2.h&gt;

#define WM_SOCKET_NOTIFY (WM_USER + 1)

#define Bu 1

SOCKET listen_socket,listen_socket2;

void initwinsock()
{

	WORD wVersionRequested;
	WSADATA wsaData;

	wVersionRequested = MAKEWORD( 2, 0 );

	WSAStartup( wVersionRequested, &amp;wsaData );

	}

void winsockconnect(HWND hwnd)
{
	listen_socket = socket(AF_INET,SOCK_STREAM,0);

	struct sockaddr_in addy2;

	addy2.sin_family = AF_INET;
    addy2.sin_port = htons(1234);

	addy2.sin_addr.s_addr = inet_addr(&quot;192.168.178.11&quot;);
		bind(listen_socket,(struct sockaddr*)&amp;addy2, sizeof(addy2));
	   listen(listen_socket, 5);
 	MessageBox(hwnd,&quot;Bind ist erfolgreich! Listen()... &quot;,&quot;Hinweis!&quot;,MB_ICONINFORMATION);
}

void closewinsock()
{
	WSASendDisconnect(listen_socket, NULL);
	closesocket(listen_socket);
	WSACleanup();
}

/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/*  Make the class name into a global variable  */
char szClassName[ ] = &quot;WindowsApp&quot;;

int WINAPI WinMain (HINSTANCE hThisInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpszArgument,
                    int nFunsterStil)

{
    HWND hwnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASSEX wincl;        /* Data structure for the windowclass */

    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
    wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;                 /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use Windows's default color as the background of the window */
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&amp;wincl))
        return 0;

    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           &quot;Windows App&quot;,       /* Title Text */
           WS_OVERLAPPEDWINDOW, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           200,                 /* The programs width */
           200,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );

    /* Make the window visible on the screen */
    ShowWindow (hwnd, nFunsterStil);

    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&amp;messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&amp;messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&amp;messages);
    }

    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
}

/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
 HWND hwbu;
 char data[]=&quot;Hallo Client!&quot;;
 int bytes;
    switch (message)                  /* handle the messages */
    {

            case WM_CREATE :

		hwbu = CreateWindow (&quot;button&quot;, &quot;Listen()...&quot;,
				  WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
				  0, 0, 60, 20, hwnd, (HMENU) Bu,
				  ((LPCREATESTRUCT) lParam) -&gt; hInstance, NULL) ;//Button &quot;=&quot; bzw. Berechne

                return 0 ; 

          case WM_COMMAND:
			  switch (HIWORD(wParam))
			  {
			  case BN_CLICKED:
				  switch(LOWORD(wParam))
				  {
				  case Bu://Button but (hwndbut)
					  initwinsock();
					  winsockconnect(hwnd);
					  	WSAAsyncSelect(listen_socket,hwnd,WM_SOCKET_NOTIFY,FD_READ|FD_CLOSE|FD_ACCEPT);

					  break;
				  }
				  break;
			  }
			  return 0;

        	case WM_SOCKET_NOTIFY:
			switch(LOWORD(lParam))
			{
			case FD_READ:

			return 0;

			case FD_ACCEPT:

     			listen_socket = accept(listen_socket,0,0);

     			if(listen_socket == INVALID_SOCKET)
     			MessageBox(hwnd,&quot;Verbindung fehlgeschlagen!&quot;,&quot;Hinweis!&quot;,MB_ICONINFORMATION);    
                 else      
                 MessageBox(hwnd,&quot;Sie sind nun verbunden!&quot;,&quot;Hinweis!&quot;,MB_ICONINFORMATION);          
				return 0;

               bytes = send(listen_socket,data,strlen(data),0);

    if (bytes == -1)
	{
		 MessageBox(hwnd,&quot;Zeichen konnten nicht gesendet werden!&quot;,&quot;Hinweis!&quot;,MB_ICONINFORMATION);    
		return -1;
	}

			case FD_CLOSE:
                closewinsock();
				MessageBox(hwnd,&quot;Verbindung beendet!&quot;,&quot;Hinweis!&quot;,MB_ICONINFORMATION);      

				return 0;
			} 

        case WM_DESTROY:

            closewinsock();
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            break;
        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}
</code></pre>
<p>CLIENT :</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;winsock2.h&gt;

#define WM_SOCKET_NOTIFY (WM_USER + 1)

#define Bu 1

SOCKET connect_socket;

void initwinsock()
{

	WORD wVersionRequested;
	WSADATA wsaData;

	wVersionRequested = MAKEWORD( 2, 0 );

	WSAStartup( wVersionRequested, &amp;wsaData );

	}

void winsockconnect(HWND hwnd)
{
	connect_socket = socket(AF_INET,SOCK_STREAM,0);

	struct sockaddr_in addy2;

	addy2.sin_family = AF_INET;
    addy2.sin_port = htons(1234);

	addy2.sin_addr.s_addr = inet_addr(&quot;192.168.178.11&quot;);
		bind(connect_socket,(struct sockaddr*)&amp;addy2, sizeof(addy2));

		if(connect(connect_socket,(struct sockaddr*)&amp;addy2,sizeof(addy2))==SOCKET_ERROR){
	MessageBox(0,&quot;Bei connect()&quot;,&quot;Socket Error&quot;,0);}

else {                        

     WSAAsyncSelect(connect_socket,hwnd,WM_SOCKET_NOTIFY,FD_CONNECT|FD_READ|FD_CLOSE); }

}

void closewinsock()
{
	WSASendDisconnect(connect_socket, NULL);
	closesocket(connect_socket);
	WSACleanup();
}

/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/*  Make the class name into a global variable  */
char szClassName[ ] = &quot;WindowsApp&quot;;

int WINAPI WinMain (HINSTANCE hThisInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpszArgument,
                    int nFunsterStil)

{
    HWND hwnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASSEX wincl;        /* Data structure for the windowclass */

    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
    wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;                 /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use Windows's default color as the background of the window */
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&amp;wincl))
        return 0;

    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           &quot;Windows App&quot;,       /* Title Text */
           WS_OVERLAPPEDWINDOW, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           200,                 /* The programs width */
           200,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );

    /* Make the window visible on the screen */
    ShowWindow (hwnd, nFunsterStil);

    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&amp;messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&amp;messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&amp;messages);
    }

    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
}

/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{ HWND hwbu;
				int ilen;
                char data[255];
    switch (message)                  /* handle the messages */
    {

            case WM_CREATE :

		hwbu = CreateWindow (&quot;button&quot;, &quot;Connect()...&quot;,
				  WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
				  0, 0, 80, 20, hwnd, (HMENU) Bu,
				  ((LPCREATESTRUCT) lParam) -&gt; hInstance, NULL) ;//Button &quot;=&quot; bzw. Berechne

                return 0 ; 

          case WM_COMMAND:
			  switch (HIWORD(wParam))
			  {
			  case BN_CLICKED:
				  switch(LOWORD(wParam))
				  {
				  case Bu://Button but (hwndbut)
					  initwinsock();
					  winsockconnect(hwnd);

					  break;
				  }
				  break;
			  }
			  return 0;

        	case WM_SOCKET_NOTIFY:
			switch(LOWORD(lParam))
			{
			case FD_READ:

                ilen = recv(connect_socket,data,255,0);
                data[ilen]='\0';

                MessageBox(hwnd,data,&quot;Nachricht vom Server :&quot;,MB_ICONINFORMATION);   

				return 0;

            case FD_CONNECT:

                 MessageBox(hwnd,&quot;Verbindung hergestellt!&quot;,&quot;Hinweis!&quot;,MB_ICONINFORMATION);   

                 return 0;

			case FD_CLOSE:
                closewinsock(); 
				MessageBox(hwnd,&quot;Verbindung beendet!&quot;,&quot;Hinweis!&quot;,MB_ICONINFORMATION);   

				return 0;
			} 

        case WM_DESTROY:

             closewinsock();
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            break;
        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}
</code></pre>
<p>Bei beiden Projekten ist natürlich noch die libws2.a gelinkt...<br />
Der CLient connected zwar richtig auf den Server allerdings wird nicht das event FD_CONNECT abgegeben ??? Und wenn ich ne Text Message schicke funktioniert das leider auch nicht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> Könnt ihr helfen ???</p>
<p>mfg FoX</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/173274/problem-mit-socket</link><generator>RSS for Node</generator><lastBuildDate>Mon, 13 Jul 2026 11:10:12 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/173274.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 13 Feb 2007 15:30:26 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem mit Socket on Tue, 13 Feb 2007 15:30:26 GMT]]></title><description><![CDATA[<p>Hi, hab das PRoblem, dass das FD_CONNECT evnet und das FD_READ event nicht funktionieren! (Beim Clienten)</p>
<p>SERVER:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;winsock2.h&gt;

#define WM_SOCKET_NOTIFY (WM_USER + 1)

#define Bu 1

SOCKET listen_socket,listen_socket2;

void initwinsock()
{

	WORD wVersionRequested;
	WSADATA wsaData;

	wVersionRequested = MAKEWORD( 2, 0 );

	WSAStartup( wVersionRequested, &amp;wsaData );

	}

void winsockconnect(HWND hwnd)
{
	listen_socket = socket(AF_INET,SOCK_STREAM,0);

	struct sockaddr_in addy2;

	addy2.sin_family = AF_INET;
    addy2.sin_port = htons(1234);

	addy2.sin_addr.s_addr = inet_addr(&quot;192.168.178.11&quot;);
		bind(listen_socket,(struct sockaddr*)&amp;addy2, sizeof(addy2));
	   listen(listen_socket, 5);
 	MessageBox(hwnd,&quot;Bind ist erfolgreich! Listen()... &quot;,&quot;Hinweis!&quot;,MB_ICONINFORMATION);
}

void closewinsock()
{
	WSASendDisconnect(listen_socket, NULL);
	closesocket(listen_socket);
	WSACleanup();
}

/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/*  Make the class name into a global variable  */
char szClassName[ ] = &quot;WindowsApp&quot;;

int WINAPI WinMain (HINSTANCE hThisInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpszArgument,
                    int nFunsterStil)

{
    HWND hwnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASSEX wincl;        /* Data structure for the windowclass */

    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
    wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;                 /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use Windows's default color as the background of the window */
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&amp;wincl))
        return 0;

    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           &quot;Windows App&quot;,       /* Title Text */
           WS_OVERLAPPEDWINDOW, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           200,                 /* The programs width */
           200,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );

    /* Make the window visible on the screen */
    ShowWindow (hwnd, nFunsterStil);

    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&amp;messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&amp;messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&amp;messages);
    }

    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
}

/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
 HWND hwbu;
 char data[]=&quot;Hallo Client!&quot;;
 int bytes;
    switch (message)                  /* handle the messages */
    {

            case WM_CREATE :

		hwbu = CreateWindow (&quot;button&quot;, &quot;Listen()...&quot;,
				  WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
				  0, 0, 60, 20, hwnd, (HMENU) Bu,
				  ((LPCREATESTRUCT) lParam) -&gt; hInstance, NULL) ;//Button &quot;=&quot; bzw. Berechne

                return 0 ; 

          case WM_COMMAND:
			  switch (HIWORD(wParam))
			  {
			  case BN_CLICKED:
				  switch(LOWORD(wParam))
				  {
				  case Bu://Button but (hwndbut)
					  initwinsock();
					  winsockconnect(hwnd);
					  	WSAAsyncSelect(listen_socket,hwnd,WM_SOCKET_NOTIFY,FD_READ|FD_CLOSE|FD_ACCEPT);

					  break;
				  }
				  break;
			  }
			  return 0;

        	case WM_SOCKET_NOTIFY:
			switch(LOWORD(lParam))
			{
			case FD_READ:

			return 0;

			case FD_ACCEPT:

     			listen_socket = accept(listen_socket,0,0);

     			if(listen_socket == INVALID_SOCKET)
     			MessageBox(hwnd,&quot;Verbindung fehlgeschlagen!&quot;,&quot;Hinweis!&quot;,MB_ICONINFORMATION);    
                 else      
                 MessageBox(hwnd,&quot;Sie sind nun verbunden!&quot;,&quot;Hinweis!&quot;,MB_ICONINFORMATION);          
				return 0;

               bytes = send(listen_socket,data,strlen(data),0);

    if (bytes == -1)
	{
		 MessageBox(hwnd,&quot;Zeichen konnten nicht gesendet werden!&quot;,&quot;Hinweis!&quot;,MB_ICONINFORMATION);    
		return -1;
	}

			case FD_CLOSE:
                closewinsock();
				MessageBox(hwnd,&quot;Verbindung beendet!&quot;,&quot;Hinweis!&quot;,MB_ICONINFORMATION);      

				return 0;
			} 

        case WM_DESTROY:

            closewinsock();
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            break;
        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}
</code></pre>
<p>CLIENT :</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;winsock2.h&gt;

#define WM_SOCKET_NOTIFY (WM_USER + 1)

#define Bu 1

SOCKET connect_socket;

void initwinsock()
{

	WORD wVersionRequested;
	WSADATA wsaData;

	wVersionRequested = MAKEWORD( 2, 0 );

	WSAStartup( wVersionRequested, &amp;wsaData );

	}

void winsockconnect(HWND hwnd)
{
	connect_socket = socket(AF_INET,SOCK_STREAM,0);

	struct sockaddr_in addy2;

	addy2.sin_family = AF_INET;
    addy2.sin_port = htons(1234);

	addy2.sin_addr.s_addr = inet_addr(&quot;192.168.178.11&quot;);
		bind(connect_socket,(struct sockaddr*)&amp;addy2, sizeof(addy2));

		if(connect(connect_socket,(struct sockaddr*)&amp;addy2,sizeof(addy2))==SOCKET_ERROR){
	MessageBox(0,&quot;Bei connect()&quot;,&quot;Socket Error&quot;,0);}

else {                        

     WSAAsyncSelect(connect_socket,hwnd,WM_SOCKET_NOTIFY,FD_CONNECT|FD_READ|FD_CLOSE); }

}

void closewinsock()
{
	WSASendDisconnect(connect_socket, NULL);
	closesocket(connect_socket);
	WSACleanup();
}

/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/*  Make the class name into a global variable  */
char szClassName[ ] = &quot;WindowsApp&quot;;

int WINAPI WinMain (HINSTANCE hThisInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpszArgument,
                    int nFunsterStil)

{
    HWND hwnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASSEX wincl;        /* Data structure for the windowclass */

    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
    wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;                 /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use Windows's default color as the background of the window */
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&amp;wincl))
        return 0;

    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           &quot;Windows App&quot;,       /* Title Text */
           WS_OVERLAPPEDWINDOW, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           200,                 /* The programs width */
           200,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );

    /* Make the window visible on the screen */
    ShowWindow (hwnd, nFunsterStil);

    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&amp;messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&amp;messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&amp;messages);
    }

    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
}

/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{ HWND hwbu;
				int ilen;
                char data[255];
    switch (message)                  /* handle the messages */
    {

            case WM_CREATE :

		hwbu = CreateWindow (&quot;button&quot;, &quot;Connect()...&quot;,
				  WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
				  0, 0, 80, 20, hwnd, (HMENU) Bu,
				  ((LPCREATESTRUCT) lParam) -&gt; hInstance, NULL) ;//Button &quot;=&quot; bzw. Berechne

                return 0 ; 

          case WM_COMMAND:
			  switch (HIWORD(wParam))
			  {
			  case BN_CLICKED:
				  switch(LOWORD(wParam))
				  {
				  case Bu://Button but (hwndbut)
					  initwinsock();
					  winsockconnect(hwnd);

					  break;
				  }
				  break;
			  }
			  return 0;

        	case WM_SOCKET_NOTIFY:
			switch(LOWORD(lParam))
			{
			case FD_READ:

                ilen = recv(connect_socket,data,255,0);
                data[ilen]='\0';

                MessageBox(hwnd,data,&quot;Nachricht vom Server :&quot;,MB_ICONINFORMATION);   

				return 0;

            case FD_CONNECT:

                 MessageBox(hwnd,&quot;Verbindung hergestellt!&quot;,&quot;Hinweis!&quot;,MB_ICONINFORMATION);   

                 return 0;

			case FD_CLOSE:
                closewinsock(); 
				MessageBox(hwnd,&quot;Verbindung beendet!&quot;,&quot;Hinweis!&quot;,MB_ICONINFORMATION);   

				return 0;
			} 

        case WM_DESTROY:

             closewinsock();
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            break;
        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}
</code></pre>
<p>Bei beiden Projekten ist natürlich noch die libws2.a gelinkt...<br />
Der CLient connected zwar richtig auf den Server allerdings wird nicht das event FD_CONNECT abgegeben ??? Und wenn ich ne Text Message schicke funktioniert das leider auch nicht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> Könnt ihr helfen ???</p>
<p>mfg FoX</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1228228</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1228228</guid><dc:creator><![CDATA[Foxx90]]></dc:creator><pubDate>Tue, 13 Feb 2007 15:30:26 GMT</pubDate></item></channel></rss>