<?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 Socket Accept abort behaviour problem in MQX Software Solutions</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/Socket-Accept-abort-behaviour-problem/m-p/279781#M8709</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am working on a product which uses the Telnet server code supplied with RTCS.&lt;/P&gt;&lt;P&gt;In the product the server needs to be started and stopped on demand.&lt;/P&gt;&lt;P&gt;During testing it was noticed that the server creates 2 sockets when started, but when the server is shut down only one socket is closed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have looked through the code and it seems that in the&amp;nbsp; SOCK_STREAM_accept function a new socket is created, then the task blocks waiting for a connection.&lt;/P&gt;&lt;P&gt;When the server is shut down, the task exit handler is called, which frees the first socket, but the second socket is left.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This process is repeated each time the server is started or stopped.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any work-around you can suggest for this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 26 Dec 2013 22:49:58 GMT</pubDate>
    <dc:creator>chrissolomon</dc:creator>
    <dc:date>2013-12-26T22:49:58Z</dc:date>
    <item>
      <title>Socket Accept abort behaviour problem</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Socket-Accept-abort-behaviour-problem/m-p/279781#M8709</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am working on a product which uses the Telnet server code supplied with RTCS.&lt;/P&gt;&lt;P&gt;In the product the server needs to be started and stopped on demand.&lt;/P&gt;&lt;P&gt;During testing it was noticed that the server creates 2 sockets when started, but when the server is shut down only one socket is closed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have looked through the code and it seems that in the&amp;nbsp; SOCK_STREAM_accept function a new socket is created, then the task blocks waiting for a connection.&lt;/P&gt;&lt;P&gt;When the server is shut down, the task exit handler is called, which frees the first socket, but the second socket is left.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This process is repeated each time the server is started or stopped.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any work-around you can suggest for this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Dec 2013 22:49:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Socket-Accept-abort-behaviour-problem/m-p/279781#M8709</guid>
      <dc:creator>chrissolomon</dc:creator>
      <dc:date>2013-12-26T22:49:58Z</dc:date>
    </item>
    <item>
      <title>Re: Socket Accept abort behaviour problem</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Socket-Accept-abort-behaviour-problem/m-p/279782#M8710</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, I've found a solution - I have modified tcp_clos.c - I've changed TCP_Close_TCB, adding the following to the end of that function:&lt;/P&gt;&lt;P&gt;/*&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Close any sockets opened by accept&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; prev_req = NULL;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; req = tcp_cfg-&amp;gt;OPENS;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; while( req != NULL )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if( ( req-&amp;gt;TCB_PTR == tcb ) &amp;amp;&amp;amp; ( ( ( SOCKET_STRUCT_PTR )req-&amp;gt;SOCKET )-&amp;gt;TCB_PTR == NULL ) ) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; void * toBeFreed = req;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SOCK_Free_sock_struct( ( SOCKET_STRUCT_PTR )req-&amp;gt;SOCKET );&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Just in case any thread is blocked waiting for this, send req complete.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RTCSCMD_complete( req, RTCSERR_TCP_CONN_RLSD );&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Remove the request from the open requests list&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if( prev_req != NULL ) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; prev_req-&amp;gt;NEXT = req-&amp;gt;NEXT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tcp_cfg-&amp;gt;OPENS = req-&amp;gt;NEXT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Move on to the next request&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; req = req-&amp;gt;NEXT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Free the old request.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _mem_free( toBeFreed );&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; prev_req = req;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; req = req-&amp;gt;NEXT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This looks for any Open Requests with the same TCB pointer in the request (the TCB of the listening socket), and where the socket has a NULL TCB pointer, and frees the socket.&lt;/P&gt;&lt;P&gt;This does not free any sockets that were spawned by the listening socket that have connected (the socket TCB wouldn't be NULL in that case).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jan 2014 21:03:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Socket-Accept-abort-behaviour-problem/m-p/279782#M8710</guid>
      <dc:creator>chrissolomon</dc:creator>
      <dc:date>2014-01-02T21:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: Socket Accept abort behaviour problem</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Socket-Accept-abort-behaviour-problem/m-p/279783#M8711</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I came across this problem also a while back. I had a similar solution, but I think I like yours better. I didnt do this: RTCSCMD_complete( req, RTCSERR_TCP_CONN_RLSD ); I'm going to try it out. Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Jan 2014 21:36:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Socket-Accept-abort-behaviour-problem/m-p/279783#M8711</guid>
      <dc:creator>larrydemuth</dc:creator>
      <dc:date>2014-01-10T21:36:49Z</dc:date>
    </item>
  </channel>
</rss>

