<?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=269049&amp;view=findpost&amp;p=2236433</guid>
        <pubDate>Mon, 06 Apr 2009 07:04:54 +0000</pubDate>
        <title>Нет возврата из функции accept</title>
        <link>https://forum.sources.ru/index.php?showtopic=269049&amp;view=findpost&amp;p=2236433</link>
        <description><![CDATA[Ofer: <strong class='tag-b'>Dem_max</strong>, все верно... Я не правильно понял справку.<br>
<br>
<strong class='tag-b'>Oleg2004</strong>, спасибо, учел :)]]></description>
        <author>Ofer</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=269049&amp;view=findpost&amp;p=2235037</guid>
        <pubDate>Fri, 03 Apr 2009 14:19:56 +0000</pubDate>
        <title>Нет возврата из функции accept</title>
        <link>https://forum.sources.ru/index.php?showtopic=269049&amp;view=findpost&amp;p=2235037</link>
        <description><![CDATA[Oleg2004: sin.sin_port = 3331;<br><br>А где преобразование порта в сетевой порядок? htons()?]]></description>
        <author>Oleg2004</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=269049&amp;view=findpost&amp;p=2234066</guid>
        <pubDate>Thu, 02 Apr 2009 14:35:38 +0000</pubDate>
        <title>Нет возврата из функции accept</title>
        <link>https://forum.sources.ru/index.php?showtopic=269049&amp;view=findpost&amp;p=2234066</link>
        <description><![CDATA[Dem_max: <strong class='tag-b'>Ofer</strong><br>
Нувообщето <strong class='tag-b'>accept</strong> нужно применять если есть входящее подключение, а если и нету ни одного а ты вызвал функцию вот она и забрала на себя управление и ждет входящего подключения<br>
<div class='tag-quote'><span class='tag-quote-prefix'>Цитата</span> <div class='quote '>Remarks<br>
<br>
This routine extracts the first connection on the queue of pending connections on s, creates a new socket and returns a handle to the new socket. The newly created socket has the same properties as s including asynchronous events registered with WSAAsyncSelect or with WSAEventSelect, but not including the listening socket&#39;s group ID, if any. If no pending connections are present on the queue, and the socket is not marked as nonblocking, accept blocks the caller until a connection is present. If the socket is marked nonblocking and no pending connections are present on the queue, accept returns an error as described below. The accepted socket cannot be used to accept more connections. The original socket remains open.</div></div>]]></description>
        <author>Dem_max</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=269049&amp;view=findpost&amp;p=2233973</guid>
        <pubDate>Thu, 02 Apr 2009 12:54:49 +0000</pubDate>
        <title>Нет возврата из функции accept</title>
        <link>https://forum.sources.ru/index.php?showtopic=269049&amp;view=findpost&amp;p=2233973</link>
        <description><![CDATA[Ofer: После вызова accept не возвращается управление в программу. По крайней мере, не выводится на экран сообщение, следующее за вызовом этой функции. Почему?<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">// MyConsoleServer.cpp : Defines the entry point for the console application.</div><div class="code_line">//</div><div class="code_line">//#pragma comment (lib, &quot;wsock32.lib&quot;)</div><div class="code_line">&nbsp;</div><div class="code_line">#include &quot;stdafx.h&quot;</div><div class="code_line">#include &#60;conio.h&#62;</div><div class="code_line">#include &#60;winsock2.h&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">int _tmain(int argc, _TCHAR* argv[])</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;WSADATA WsaData;</div><div class="code_line">&nbsp;&nbsp; &nbsp;SOCKET s,s1;</div><div class="code_line">&nbsp;&nbsp; &nbsp;SOCKADDR_IN sin,from;</div><div class="code_line">&nbsp;&nbsp; &nbsp;char *RecvBuffer;</div><div class="code_line">&nbsp;&nbsp; &nbsp;char *MsgText;</div><div class="code_line">&nbsp;&nbsp; &nbsp;int err,fromlen;</div><div class="code_line">&nbsp;&nbsp; &nbsp;MsgText = &quot;&#60;html&#62;&#60;b&#62;Hello!!&#60;/b&#62;&#60;/html&#62;&quot;;</div><div class="code_line">&nbsp;&nbsp; &nbsp;err = WSAStartup(0x0101,&amp;WsaData);</div><div class="code_line">&nbsp;&nbsp; &nbsp;if(err == SOCKET_ERROR)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;printf(&quot;WsaStartup() failed: %ld\n&quot;,GetLastError());</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;&nbsp; &nbsp;s = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);</div><div class="code_line">&nbsp;&nbsp; &nbsp;sin.sin_family = AF_INET;</div><div class="code_line">&nbsp;&nbsp; &nbsp;sin.sin_port = 3331;</div><div class="code_line">&nbsp;&nbsp; &nbsp;sin.sin_addr.s_addr = INADDR_ANY;</div><div class="code_line">&nbsp;&nbsp; &nbsp;err = bind(s,(LPSOCKADDR)&amp;sin,sizeof(sin));</div><div class="code_line">&nbsp;&nbsp; &nbsp;err = listen(s,SOMAXCONN);</div><div class="code_line">&nbsp;&nbsp; &nbsp;fromlen = sizeof(from);</div><div class="code_line">&nbsp;&nbsp; &nbsp;s1 = accept(s,(struct sockaddr*)&amp;from,&amp;fromlen);</div><div class="code_line">&nbsp;&nbsp; &nbsp;printf(&quot;accept connection from %s, port %d\n&quot;, inet_ntoa(from.sin_addr),htons(from.sin_port));</div><div class="code_line">&nbsp;&nbsp; &nbsp;while(recv(s1,RecvBuffer,sizeof(RecvBuffer),0)!=SOCKET_ERROR)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;printf(&quot;%c&quot;,RecvBuffer[0]);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;send(s1,MsgText,sizeof(MsgText),MSG_DONTROUTE);</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;return 0;</div><div class="code_line">}</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script>]]></description>
        <author>Ofer</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      </channel>
      </rss>
	