<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Unexpected behavior with RTCS_selectset() and accept() for TCP server socket in MQX Software Solutions</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/Unexpected-behavior-with-RTCS-selectset-and-accept-for-TCP/m-p/148311#M255</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi Tim,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sometimes it is necessary to release the sockets from connections that were closed. It happened to me that I wasn't closing the sockets of clients that were leaving the server and the resources weren't been released by MQX in a big period of time and then there were no more resources to create new sockets for the new incomming connections.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you closing the sockets in the server side once the client left the connection?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps.&lt;/P&gt;&lt;P&gt;Garabo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 13 Sep 2012 15:52:40 GMT</pubDate>
    <dc:creator>Luis_Garabo</dc:creator>
    <dc:date>2012-09-13T15:52:40Z</dc:date>
    <item>
      <title>Unexpected behavior with RTCS_selectset() and accept() for TCP server socket</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Unexpected-behavior-with-RTCS-selectset-and-accept-for-TCP/m-p/148308#M252</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am running a Kinetis K60 Tower.&lt;/P&gt;&lt;P&gt;I have a simple TCP server setup to listen for incoming client connections. I am able to detect (with RTCS_selectset) and accept incoming client connections as expected for a few connections (say 10-15) . Then randomly upon attempting to connect to the server, the listening sever socket enters a state where RTCS_selectset() will immediately return indicating there is a client ready, accept return immediately with return code&amp;nbsp;RTCS_SOCKET_ERROR. However when calling&amp;nbsp;RTCS_geterror(server_socket) I get RTCS_OK. It is like select says a client is waiting to connect, and accept is trying but failing to accpet the connection - but not providing an error.&lt;/P&gt;&lt;P&gt;Furthermore when this state is entered, even shutting down and and creating a new server socket continue to behave this way. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Tim&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;while(retry){client_socket = RTCS_selectset(&amp;amp;server_socket, 1, BSP_ETHERNET_CONNECTION_TIMEOUT);  if(client_socket == RTCS_SOCKET_ERROR)   {      break;  }   else if(client_socket == server_socket)   {   client_socket = accept(server_socket, NULL, NULL);    if(client_socket == RTCS_SOCKET_ERROR)    {    int status = RTCS_geterror(server_socket);    if (status == RTCS_OK)     {     /// keeps ending up here when in bad state    }....&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 08:50:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Unexpected-behavior-with-RTCS-selectset-and-accept-for-TCP/m-p/148308#M252</guid>
      <dc:creator>tmeyer</dc:creator>
      <dc:date>2020-10-29T08:50:06Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected behavior with RTCS_selectset() and accept() for TCP server socket</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Unexpected-behavior-with-RTCS-selectset-and-accept-for-TCP/m-p/148309#M253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tim,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm afraid this is not advice, just a report of somewhat similar behavior. I am also running a simple socket server that runs ok for a while and then fails. In my case calls to RTCS_selectset on a listening socket that was working no longer signal when a connection is being attempted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (!resetip)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;rc = RTCS_selectset(&amp;amp;sock, 1, 1000);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if (rc == RTCS_SOCKET_ERROR) { err = "RTCS_selectset"; goto error; }&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if (rc == 0) { continue; }&lt;/FONT&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;/* Accept connection */&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;insock = accept(sock, &amp;amp;inaddr, &amp;amp;inaddr_len);&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 Mar 2012 01:40:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Unexpected-behavior-with-RTCS-selectset-and-accept-for-TCP/m-p/148309#M253</guid>
      <dc:creator>MPotts</dc:creator>
      <dc:date>2012-03-31T01:40:17Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected behavior with RTCS_selectset() and accept() for TCP server socket</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Unexpected-behavior-with-RTCS-selectset-and-accept-for-TCP/m-p/148310#M254</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Happens to me as well when I try to make a second connection to the same server&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any Ideas??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Edgar Sevilla&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2012 22:37:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Unexpected-behavior-with-RTCS-selectset-and-accept-for-TCP/m-p/148310#M254</guid>
      <dc:creator>edgarsevilla</dc:creator>
      <dc:date>2012-09-12T22:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected behavior with RTCS_selectset() and accept() for TCP server socket</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Unexpected-behavior-with-RTCS-selectset-and-accept-for-TCP/m-p/148311#M255</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi Tim,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sometimes it is necessary to release the sockets from connections that were closed. It happened to me that I wasn't closing the sockets of clients that were leaving the server and the resources weren't been released by MQX in a big period of time and then there were no more resources to create new sockets for the new incomming connections.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you closing the sockets in the server side once the client left the connection?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps.&lt;/P&gt;&lt;P&gt;Garabo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Sep 2012 15:52:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Unexpected-behavior-with-RTCS-selectset-and-accept-for-TCP/m-p/148311#M255</guid>
      <dc:creator>Luis_Garabo</dc:creator>
      <dc:date>2012-09-13T15:52:40Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected behavior with RTCS_selectset() and accept() for TCP server socket</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Unexpected-behavior-with-RTCS-selectset-and-accept-for-TCP/m-p/148312#M256</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I found the problem to be using&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shutdown(sock, FLAG_CLOSE_TX);&lt;/P&gt;&lt;P&gt;which does not release the internal socket context for four minutes. Using&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shutdown(sock, FLAG_ABORT_CONNECTION);&lt;/P&gt;&lt;P&gt;released the socket context immediately and accepted another connection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Oct 2012 22:09:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Unexpected-behavior-with-RTCS-selectset-and-accept-for-TCP/m-p/148312#M256</guid>
      <dc:creator>MPotts</dc:creator>
      <dc:date>2012-10-08T22:09:28Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected behavior with RTCS_selectset() and accept() for TCP server socket</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Unexpected-behavior-with-RTCS-selectset-and-accept-for-TCP/m-p/148313#M257</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is good you foind the solution! Congrats!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Oct 2012 20:25:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Unexpected-behavior-with-RTCS-selectset-and-accept-for-TCP/m-p/148313#M257</guid>
      <dc:creator>Luis_Garabo</dc:creator>
      <dc:date>2012-10-11T20:25:24Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected behavior with RTCS_selectset() and accept() for TCP server socket</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Unexpected-behavior-with-RTCS-selectset-and-accept-for-TCP/m-p/148314#M258</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Can anyone tell how to know , whether socket is shutdown or not??&lt;/P&gt;&lt;P&gt;after shutting down&amp;nbsp; the socket , still i am unable to create to create socket again.&lt;/P&gt;&lt;P&gt;It throwing error in bind().&lt;/P&gt;&lt;P&gt;Plz reply&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Netra&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Nov 2012 15:38:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Unexpected-behavior-with-RTCS-selectset-and-accept-for-TCP/m-p/148314#M258</guid>
      <dc:creator>netra</dc:creator>
      <dc:date>2012-11-20T15:38:51Z</dc:date>
    </item>
  </channel>
</rss>

