<?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 SOckets -&amp;gt; FD_CONNECT]]></title><description><![CDATA[<p>Hi, ich hab jetzt schon fast alles ausprobiert...ABER egal was ich mache... FD_CONNECT wird beim Clienten einfach nicht gepostet! Alles funktioniert... FD_READ, FD_CLOSE .... Also ich kann strings verschicken und empfangen... aber aus ieinem grund funktioniert es nicht eine Bestätigung als Client zu erhalten, wenn die Anfrage akzeptiert wurde... Ich hoffe ihr könnt helfEn !!!</p>
<p>Server Socket Teil</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;winsock2.h&gt;

#define WM_SOCKET_NOTIFY (WM_USER + 1)

...

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;127.0.0.1&quot;);

	bind(listen_socket,(struct sockaddr*)&amp;addy2, sizeof(addy2));

WSAAsyncSelect(listen_socket,hwnd,WM_SOCKET_NOTIFY,FD_READ|FD_CLOSE|FD_ACCEPT);

	listen(listen_socket, 5);

 	MessageBox(hwnd,&quot;Bind ist erfolgreich! Listen()... &quot;,&quot;Hinweis!&quot;,MB_ICONINFORMATION);
}

void closewinsock(HWND hwnd)
{
    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);    

	} 

	WSASendDisconnect(listen_socket, NULL);
	closesocket(listen_socket);
	WSACleanup();
}

...

        	case WM_SOCKET_NOTIFY:

                 SocketEvent = WSAGETSELECTEVENT(lParam);   

                 Socket = (SOCKET) wParam;

			switch(SocketEvent)
			{
			case FD_READ:

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

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

			return 0;

			case FD_ACCEPT:

                len = sizeof(client);

     		listen_socket = accept(Socket,(struct sockaddr*)&amp;client, &amp;len);

     			if(listen_socket == INVALID_SOCKET)

     			MessageBox(hwnd,&quot;Verbindung fehlgeschlagen!&quot;,&quot;Hinweis!&quot;,MB_ICONINFORMATION);    
                 else      
                 MessageBox(hwnd,inet_ntoa(client.sin_addr),&quot;Clientdaten&quot;,MB_ICONINFORMATION);          
				return 0;

			case FD_CLOSE:

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

				return 0;
}
</code></pre>
<p>So der Server macht keine Probleme... Er bekommt das FD_ACCEPT Event gepostet und reagiert dementsprechend... aber wenn der Server die Verbindung eingeht...bekommt der Client kein FD_CONNECT <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="😕"
    /> WARUM <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>
<p>Client Teil</p>
<pre><code class="language-cpp">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;127.0.0.1&quot;);

        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(HWND hwnd)
{
    bytes = send(connect_socket,data,strlen(data),0);

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

	} 

	WSASendDisconnect(connect_socket, NULL);
	closesocket(connect_socket);
	WSACleanup();
}

...

	case WM_SOCKET_NOTIFY:

              SocketEvent = WSAGETSELECTEVENT(lParam);   

			switch(SocketEvent)
			{
			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);   &lt;-- DIESE MESSAGE BOX EINFACH nicht! :(

                 return 0;

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

				return 0;
			}
</code></pre>
<p>Also wo liegt der Fehler ?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/173348/problem-mit-sockets-gt-fd_connect</link><generator>RSS for Node</generator><lastBuildDate>Mon, 13 Jul 2026 06:34:54 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/173348.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 14 Feb 2007 12:55:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to PROBLEM MIT SOckets -&amp;gt; FD_CONNECT on Wed, 14 Feb 2007 12:55:42 GMT]]></title><description><![CDATA[<p>Hi, ich hab jetzt schon fast alles ausprobiert...ABER egal was ich mache... FD_CONNECT wird beim Clienten einfach nicht gepostet! Alles funktioniert... FD_READ, FD_CLOSE .... Also ich kann strings verschicken und empfangen... aber aus ieinem grund funktioniert es nicht eine Bestätigung als Client zu erhalten, wenn die Anfrage akzeptiert wurde... Ich hoffe ihr könnt helfEn !!!</p>
<p>Server Socket Teil</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;winsock2.h&gt;

#define WM_SOCKET_NOTIFY (WM_USER + 1)

...

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;127.0.0.1&quot;);

	bind(listen_socket,(struct sockaddr*)&amp;addy2, sizeof(addy2));

WSAAsyncSelect(listen_socket,hwnd,WM_SOCKET_NOTIFY,FD_READ|FD_CLOSE|FD_ACCEPT);

	listen(listen_socket, 5);

 	MessageBox(hwnd,&quot;Bind ist erfolgreich! Listen()... &quot;,&quot;Hinweis!&quot;,MB_ICONINFORMATION);
}

void closewinsock(HWND hwnd)
{
    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);    

	} 

	WSASendDisconnect(listen_socket, NULL);
	closesocket(listen_socket);
	WSACleanup();
}

...

        	case WM_SOCKET_NOTIFY:

                 SocketEvent = WSAGETSELECTEVENT(lParam);   

                 Socket = (SOCKET) wParam;

			switch(SocketEvent)
			{
			case FD_READ:

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

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

			return 0;

			case FD_ACCEPT:

                len = sizeof(client);

     		listen_socket = accept(Socket,(struct sockaddr*)&amp;client, &amp;len);

     			if(listen_socket == INVALID_SOCKET)

     			MessageBox(hwnd,&quot;Verbindung fehlgeschlagen!&quot;,&quot;Hinweis!&quot;,MB_ICONINFORMATION);    
                 else      
                 MessageBox(hwnd,inet_ntoa(client.sin_addr),&quot;Clientdaten&quot;,MB_ICONINFORMATION);          
				return 0;

			case FD_CLOSE:

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

				return 0;
}
</code></pre>
<p>So der Server macht keine Probleme... Er bekommt das FD_ACCEPT Event gepostet und reagiert dementsprechend... aber wenn der Server die Verbindung eingeht...bekommt der Client kein FD_CONNECT <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="😕"
    /> WARUM <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>
<p>Client Teil</p>
<pre><code class="language-cpp">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;127.0.0.1&quot;);

        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(HWND hwnd)
{
    bytes = send(connect_socket,data,strlen(data),0);

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

	} 

	WSASendDisconnect(connect_socket, NULL);
	closesocket(connect_socket);
	WSACleanup();
}

...

	case WM_SOCKET_NOTIFY:

              SocketEvent = WSAGETSELECTEVENT(lParam);   

			switch(SocketEvent)
			{
			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);   &lt;-- DIESE MESSAGE BOX EINFACH nicht! :(

                 return 0;

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

				return 0;
			}
</code></pre>
<p>Also wo liegt der Fehler ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1228706</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1228706</guid><dc:creator><![CDATA[Foxx90]]></dc:creator><pubDate>Wed, 14 Feb 2007 12:55:42 GMT</pubDate></item><item><title><![CDATA[Reply to PROBLEM MIT SOckets -&amp;gt; FD_CONNECT on Wed, 14 Feb 2007 13:22:10 GMT]]></title><description><![CDATA[<p>Weil du connect() vor WSAAsyncSelect() ausführst?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1228738</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1228738</guid><dc:creator><![CDATA[geeky]]></dc:creator><pubDate>Wed, 14 Feb 2007 13:22:10 GMT</pubDate></item></channel></rss>