<?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>MQX Software SolutionsのトピックTCP socket connection fail when webserver is active</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/TCP-socket-connection-fail-when-webserver-is-active/m-p/259132#M7670</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now i'm using mqx 4_0_2, with cw10.4. When i try to connect with a PC to the tcp socket on a twr-k60f120m with a webserver active the connection works only the half of the time. When i deactivate the embedded webserver it's work great.&lt;/P&gt;&lt;P&gt;I have searched on differents discussion on this forum and after trying to augment the tcp socket connection limits the problem doesn't disappear.&lt;/P&gt;&lt;P&gt;Here is the code that get the incoming socket connection:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13837494602143766" jivemacro_uid="_13837494602143766"&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;//Block here until they are socket activity&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;sockSet[0] = mySocket-&amp;gt;listenSock;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;sockSet[1] = mySocket-&amp;gt;sock;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;sock = RTCS_selectset(sockSet, 2, 0);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;if(sock ==mySocket-&amp;gt;listenSock)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt; ...&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt; //Test incoming connection&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt; if(mySocket-&amp;gt;sock == 0)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt; {&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; mySocket-&amp;gt;sock = accept(mySocket-&amp;gt;listenSock, &amp;amp;mySocket-&amp;gt;remoteAddr, &amp;amp;mySocket-&amp;gt;remoteAddrLen);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; ...&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;



&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;P&gt;I don't know if they are any error in these connection logic or if are something to activate in the user_config to run the webserver and a socket connection together.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;UPDATE:&lt;/P&gt;&lt;P&gt;When the connection doesn't work, in the RTCS socket summary i see that my socket is connected and it appear a socket with ground state. When the task work well, the socket in ground state doesn't appear.&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="RTCS_SockProblem.PNG.png"&gt;&lt;IMG alt="RTCS_SockProblem.PNG.png" src="https://community.nxp.com/t5/image/serverpage/image-id/42331iA2AD791724E70A7C/image-size/large?v=v2&amp;amp;px=999" title="RTCS_SockProblem.PNG.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Any one can help me?&lt;/P&gt;&lt;P&gt;Thanks &lt;IMG alt="Smiley Happy" class="emoticon emoticon-smileyhappy" id="smileyhappy" src="https://community.nxp.com/i/smilies/16x16_smiley-happy.png" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 02 Nov 2020 13:03:20 GMT</pubDate>
    <dc:creator>michelekorell</dc:creator>
    <dc:date>2020-11-02T13:03:20Z</dc:date>
    <item>
      <title>TCP socket connection fail when webserver is active</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/TCP-socket-connection-fail-when-webserver-is-active/m-p/259132#M7670</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now i'm using mqx 4_0_2, with cw10.4. When i try to connect with a PC to the tcp socket on a twr-k60f120m with a webserver active the connection works only the half of the time. When i deactivate the embedded webserver it's work great.&lt;/P&gt;&lt;P&gt;I have searched on differents discussion on this forum and after trying to augment the tcp socket connection limits the problem doesn't disappear.&lt;/P&gt;&lt;P&gt;Here is the code that get the incoming socket connection:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13837494602143766" jivemacro_uid="_13837494602143766"&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;//Block here until they are socket activity&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;sockSet[0] = mySocket-&amp;gt;listenSock;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;sockSet[1] = mySocket-&amp;gt;sock;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;sock = RTCS_selectset(sockSet, 2, 0);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;if(sock ==mySocket-&amp;gt;listenSock)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt; ...&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt; //Test incoming connection&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt; if(mySocket-&amp;gt;sock == 0)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt; {&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; mySocket-&amp;gt;sock = accept(mySocket-&amp;gt;listenSock, &amp;amp;mySocket-&amp;gt;remoteAddr, &amp;amp;mySocket-&amp;gt;remoteAddrLen);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; ...&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;



&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;P&gt;I don't know if they are any error in these connection logic or if are something to activate in the user_config to run the webserver and a socket connection together.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;UPDATE:&lt;/P&gt;&lt;P&gt;When the connection doesn't work, in the RTCS socket summary i see that my socket is connected and it appear a socket with ground state. When the task work well, the socket in ground state doesn't appear.&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="RTCS_SockProblem.PNG.png"&gt;&lt;IMG alt="RTCS_SockProblem.PNG.png" src="https://community.nxp.com/t5/image/serverpage/image-id/42331iA2AD791724E70A7C/image-size/large?v=v2&amp;amp;px=999" title="RTCS_SockProblem.PNG.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Any one can help me?&lt;/P&gt;&lt;P&gt;Thanks &lt;IMG alt="Smiley Happy" class="emoticon emoticon-smileyhappy" id="smileyhappy" src="https://community.nxp.com/i/smilies/16x16_smiley-happy.png" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2020 13:03:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/TCP-socket-connection-fail-when-webserver-is-active/m-p/259132#M7670</guid>
      <dc:creator>michelekorell</dc:creator>
      <dc:date>2020-11-02T13:03:20Z</dc:date>
    </item>
    <item>
      <title>Re: TCP socket connection fail when webserver is active</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/TCP-socket-connection-fail-when-webserver-is-active/m-p/259133#M7671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;From your description, it seems like accept() creates a new socket OK, but subsequent processing leads to an error. Accept() may return RTCS_SOCKET_ERROR and then you can call RTCS_geterror() on the listening socket to determine the cause. Errors are listed in rtcs_err.h.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Nov 2013 11:23:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/TCP-socket-connection-fail-when-webserver-is-active/m-p/259133#M7671</guid>
      <dc:creator>Martin_</dc:creator>
      <dc:date>2013-11-25T11:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: Re: TCP socket connection fail when webserver is active</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/TCP-socket-connection-fail-when-webserver-is-active/m-p/259134#M7672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hello, thanks for the quick reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have added somes debug message and I notice that when the connection doesnt work, the task is blocked into the accept(...).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here are the complete code of accept function:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13854740598889088" jivemacro_uid="_13854740598889088"&gt;
&lt;P&gt;if (mySocket-&amp;gt;sock == 0)
{
&amp;nbsp; printf("\nAccept new socket\n");
&amp;nbsp; mySocket-&amp;gt;sock = accept(mySocket-&amp;gt;listenSock, &amp;amp;mySocket-&amp;gt;remoteAddr, &amp;amp;mySocket-&amp;gt;remoteAddrLen);
&amp;nbsp; printf("\nAccept new socket on: %d\n",mySocket-&amp;gt;sock);

&amp;nbsp; if (mySocket-&amp;gt;sock == RTCS_SOCKET_ERROR)
&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("\naccept() failed, error 0x%lx", RTCS_geterror(mySocket-&amp;gt;listenSock));
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (shutdown(mySocket-&amp;gt;sock, FLAG_CLOSE_TX) != RTCS_OK)
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("\nfailed shutdown socket (sock == 0)"); //, buf);
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; else
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("\nDISCONNECTED");
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mySocket-&amp;gt;sock = 0;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; //continue;
&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp; // Send back a quote:
&amp;nbsp; printf("\nCONNECTED");
}&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;If the client disconnect and connect the task continue to work. Now I try to debug around the task execution.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Nov 2013 13:59:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/TCP-socket-connection-fail-when-webserver-is-active/m-p/259134#M7672</guid>
      <dc:creator>michelekorell</dc:creator>
      <dc:date>2013-11-26T13:59:46Z</dc:date>
    </item>
    <item>
      <title>Re: TCP socket connection fail when webserver is active</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/TCP-socket-connection-fail-when-webserver-is-active/m-p/259135#M7673</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Workaround found:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when i wait for activity and my socket is not connected I call the accept() function that block until the connection of a client. Then I wait on RTCS_selectset() to get activity on my target socket. When socket is closed I return on accept() function. If new activity on listen socket is detected i do nothing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_1386860839683998" jivemacro_uid="_1386860839683998" modifiedtitle="true"&gt;
&lt;P&gt;if(mySocket-&amp;gt;socket == 0)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mySocket-&amp;gt;sock = accept(mySocket-&amp;gt;listenSock, &amp;amp;mySocket-&amp;gt;remoteAddr, &amp;amp;mySocket-&amp;gt;remoteAddrLen); &lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;sock = RTCS_selectset(sockSet, 2, 0);&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;if(sock == mySocket-&amp;gt;sock)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; length = recv(&lt;SPAN style="color: #0000c0; font-size: 10pt;"&gt;sock&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;, mySocket-&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000c0; font-size: 10pt;"&gt;receiveBuffer&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;, mySocket-&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000c0; font-size: 10pt;"&gt;receiveBufferSize&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;, 0);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;else if(sock == RTCS_SOCKET_ERROR)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;//Handle error&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;else&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;//Handle other socket activity&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Dec 2013 15:22:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/TCP-socket-connection-fail-when-webserver-is-active/m-p/259135#M7673</guid>
      <dc:creator>michelekorell</dc:creator>
      <dc:date>2013-12-12T15:22:54Z</dc:date>
    </item>
  </channel>
</rss>

