<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=142493&amp;view=findpost&amp;p=1106268</guid>
        <pubDate>Fri, 19 May 2006 12:48:56 +0000</pubDate>
        <title>CSocket::Connect - ошибка 10038</title>
        <link>https://forum.sources.ru/index.php?showtopic=142493&amp;view=findpost&amp;p=1106268</link>
        <description><![CDATA[Oleg2004: <strong class='tag-b'>progman</strong><br>
<div class='tag-quote'><span class='tag-quote-prefix'>Цитата</span> <div class='quote '>поставил WSAStartup перед коннектом и заработало.</div></div><br>
Это виндовский закон - в любой сетевой программе надо инициализировать Winsock и затем в конце освободить все сетевые ресурсы - WSAСleanup]]></description>
        <author>Oleg2004</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=142493&amp;view=findpost&amp;p=1106119</guid>
        <pubDate>Fri, 19 May 2006 10:23:23 +0000</pubDate>
        <title>CSocket::Connect - ошибка 10038</title>
        <link>https://forum.sources.ru/index.php?showtopic=142493&amp;view=findpost&amp;p=1106119</link>
        <description><![CDATA[progman: <strong class='tag-b'>Oleg2004</strong><br>
вылезала сразу после <br>
BOOL res = pConnect-&gt;Connect(ip_address, port);<br>
<br>
клиентский сокет не мог законнекится на серверный.<br>
в инициализации окна стоял WSAStartup , очевидно не хватило одного вызова  :huh: .<br>
<br>
поставил WSAStartup  перед коннектом и заработало.]]></description>
        <author>progman</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=142493&amp;view=findpost&amp;p=1105436</guid>
        <pubDate>Thu, 18 May 2006 16:42:38 +0000</pubDate>
        <title>CSocket::Connect - ошибка 10038</title>
        <link>https://forum.sources.ru/index.php?showtopic=142493&amp;view=findpost&amp;p=1105436</link>
        <description><![CDATA[Oleg2004: <strong class='tag-b'>progman</strong><br>
Так а где - после какой функции - эта ошибка вылазит???<br>
WSAENOTSOCK (10038) Socket operation on non-socket. <br>
Berkeley description: An operation was attempted on something that is not a socket. The specified socket parameter refers to a file, not a socket. <br>
WinSock description: Same as Berkeley. The socket input parameter is not a valid socket handle (either it never was valid, it&#39;s a file handle (not a socket handle), or if it was a socket handle, it has been closed). <br>
Detailed description: <br>
<strong class='tag-b'>select(): fails with WSAENOTSOCK if any socket in an fd_set is an invalid socket handle. </strong><br>
Developer suggestions: Did you close a socket inadvertently in one part of an application without keeping another part notified? Use socket state in an application and/or handle this error gracefully as a non-fatal error. <br>
WinSock functions: Any function that takes a socket as an input parameter: accept(), bind(), closesocket(), connect(), getpeername(), getsockname(), getsockopt(), ioctl socket(), listen(), recv(), recvfrom(), select(), send(), sendto(), setsockopt(), shutdown(), FD_CONNECT <br>
Additional functions: WSAAsyncSelect() should be in the list of functions (some applications might not register for or handle the FD_CONNECT message).]]></description>
        <author>Oleg2004</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=142493&amp;view=findpost&amp;p=1104716</guid>
        <pubDate>Thu, 18 May 2006 08:00:21 +0000</pubDate>
        <title>CSocket::Connect - ошибка 10038</title>
        <link>https://forum.sources.ru/index.php?showtopic=142493&amp;view=findpost&amp;p=1104716</link>
        <description><![CDATA[progman: писал клиент-сервер. дома на тестовой машине пахало на ура.<br>
была сеть из двух машин с IP 192.168.0.1 и 192.168.0.2<br>
принес проект на работу и вот такая хрень. 10038 ошибка. кек лечить не пойму.<br>
а на работе все машины с внешними IP.<br>
клиент:<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">&nbsp;char ip_address[256];</div><div class="code_line">&nbsp;sprintf(ip_address, &quot;%d.%d.%d.%d&quot;, adr[0], adr[1], adr[2], adr[3]);</div><div class="code_line">&nbsp;&nbsp; &nbsp;</div><div class="code_line">&nbsp;int port = 2106;</div><div class="code_line">&nbsp;BOOL res = pConnect-&#62;Connect(ip_address, port);</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script><br>
<br>
server:<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">for(;;)</div><div class="code_line">&nbsp;{</div><div class="code_line">&nbsp;&nbsp; fd_set readset;</div><div class="code_line">&nbsp;&nbsp; FD_ZERO( &amp;readset );</div><div class="code_line">&nbsp;&nbsp; FD_SET( login_socket, &amp;readset );</div><div class="code_line">&nbsp;&nbsp; FD_SET( game_socket, &amp;readset );</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; for( int it = 0; it &#60; clients.GetSize(); it++)</div><div class="code_line">&nbsp;&nbsp; &nbsp;FD_SET( clients.GetAt(it)-&#62;GetSocket(), &amp;readset );</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; timeval timeout;</div><div class="code_line">&nbsp;&nbsp; timeout.tv_sec = 0;</div><div class="code_line">&nbsp;&nbsp; timeout.tv_usec = 1;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; int mx = getmax( max( login_socket, game_socket ) );</div><div class="code_line">&nbsp;&nbsp; </div><div class="code_line">&nbsp;&nbsp; if( FD_ISSET( login_socket, &amp;readset ) )</div><div class="code_line">&nbsp;&nbsp; {</div><div class="code_line">&nbsp;&nbsp; &nbsp; //this is new connect</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;// sockaddr_in login_name;</div><div class="code_line">&nbsp;&nbsp; &nbsp; int client_sock = accept( login_socket, 0, 0 );</div><div class="code_line">&nbsp;&nbsp; &nbsp; if( client_sock &#60; 0 )</div><div class="code_line">&nbsp;&nbsp; &nbsp; {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;printfex(RED, &quot;error: accept() \n&quot;);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;exit();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;closesocket( login_socket );</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;closesocket( game_socket );</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return 1;</div><div class="code_line">&nbsp;&nbsp; &nbsp; }</div><div class="code_line">&nbsp;</div><div class="code_line">// &nbsp; &nbsp; fcntl( client_sock, F_SETFL, O_NONBLOCK );</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; CClient* pClient = new CClient;</div><div class="code_line">&nbsp;&nbsp; &nbsp; pClient-&#62;SetSocket( client_sock );</div><div class="code_line">&nbsp;&nbsp; &nbsp; pClient-&#62;port = 2106;</div><div class="code_line">&nbsp;&nbsp; &nbsp; clients.add( pClient );</div><div class="code_line">&nbsp;&nbsp; &nbsp; </div><div class="code_line">&nbsp;&nbsp; &nbsp; if( -1 == m_Login-&#62;OnConnect(pClient) )</div><div class="code_line">&nbsp;&nbsp; &nbsp; {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; printfex(RED, &quot;[L2 Serever] fatal connect to 2106\n&quot;);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; remove( pClient );</div><div class="code_line">&nbsp;&nbsp; &nbsp; }</div><div class="code_line">&nbsp;&nbsp; &nbsp; else printfex(YELLOW, &quot;[L2 Serever] connect to 2106\n&quot;);</div><div class="code_line">&nbsp;&nbsp; } &nbsp;</div><div class="code_line">&nbsp;}</div></ol></div></div></div></div> <br>
<br>
<span class="tag-color tag-color-named" data-value="gray" style="color: gray"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2006-05-18T08:07:12+00:00">18.05.06, 08:07</time></span></span><br>
ЗЫ, пытался отрубить тачку от сети и поставить на ней &quot;домашние&quot; IP - один хрен не пашет. <br>
<br>
<span class="tag-color tag-color-named" data-value="gray" style="color: gray"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2006-05-18T08:52:24+00:00">18.05.06, 08:52</time></span></span><br>
млин, <br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">&nbsp;WSADATA WSAData ;</div><div class="code_line">&nbsp;if (WSAStartup (MAKEWORD(1,1), &amp;WSAData) != 0) </div><div class="code_line">&nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// &nbsp; &nbsp; &nbsp;::MessageBox (NULL, TEXT(&quot;WSAStartup failed!&quot;), TEXT(&quot;Error&quot;), MB_OK);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return;</div><div class="code_line">&nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">char ip_address[256];</div><div class="code_line">&nbsp;sprintf(ip_address, &quot;%d.%d.%d.%d&quot;, adr[0], adr[1], adr[2], adr[3]);</div><div class="code_line">&nbsp;&nbsp; &nbsp;</div><div class="code_line">&nbsp;int port = 2106;</div><div class="code_line">&nbsp;BOOL res = pConnect-&#62;Connect(ip_address, port);</div></ol></div></div></div></div><br>
<br>
однако <br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">WSADATA WSAData ;</div><div class="code_line">&nbsp;if (WSAStartup (MAKEWORD(1,1), &amp;WSAData) != 0) </div><div class="code_line">&nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// &nbsp; &nbsp; &nbsp;::MessageBox (NULL, TEXT(&quot;WSAStartup failed!&quot;), TEXT(&quot;Error&quot;), MB_OK);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return;</div><div class="code_line">&nbsp;}</div></ol></div></div></div></div><br>
<br>
вызывалось при старте программы. чудеса однако.]]></description>
        <author>progman</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      </channel>
      </rss>
	