<?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のトピックHow to test if socket connection is still there?</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-test-if-socket-connection-is-still-there/m-p/157980#M932</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am using MQX v3.6 with colfire 7.2. I have searched the board and can't find any answer so I'm putting it out there.&lt;/P&gt;&lt;P&gt;How can I check if my socket connection is still there?&lt;/P&gt;&lt;P&gt;I am using accept() and once inside it doesn't return unless the other connection has been aborted.&lt;/P&gt;&lt;P&gt;But what if the cable is diconnected or the connection is lost?&lt;/P&gt;&lt;P&gt;How can I tell?&lt;/P&gt;&lt;P&gt;In my code example I am checking each time that the server on the other side is always the original to prevent some other location from stealing my connection.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;   while(socket_flag == TRUE)    {    sock2 = accept(listensock, &amp;amp;raddr, &amp;amp;addr_length);    return_error_if(sock2 == RTCS_SOCKET_ERROR);    if(addr.sin_addr.s_addr == raddr.sin_addr.s_addr)    {     shutdown(sock, FLAG_CLOSE_TX);     fclose(sockfd);     sockfd = fopen("socket:", (char_ptr)sock2);     socket_flag = TRUE;    }    else    {     diag_led_red();     RTCS_time_delay(100);     continue;    }    sock = accept(listensock, &amp;amp;addr, &amp;amp;addr_length);    return_error_if(sock == RTCS_SOCKET_ERROR);    if(addr.sin_addr.s_addr == raddr.sin_addr.s_addr)    {     shutdown(sock2, FLAG_CLOSE_TX);     fclose(sockfd);     sockfd = fopen("socket:", (char_ptr)sock);     socket_flag = TRUE;    }    else    {     diag_led_grn();     RTCS_time_delay(100);     continue;    }           }//while(socket_flag == TRUE)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 29 Oct 2020 09:02:51 GMT</pubDate>
    <dc:creator>drummer</dc:creator>
    <dc:date>2020-10-29T09:02:51Z</dc:date>
    <item>
      <title>How to test if socket connection is still there?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-test-if-socket-connection-is-still-there/m-p/157980#M932</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am using MQX v3.6 with colfire 7.2. I have searched the board and can't find any answer so I'm putting it out there.&lt;/P&gt;&lt;P&gt;How can I check if my socket connection is still there?&lt;/P&gt;&lt;P&gt;I am using accept() and once inside it doesn't return unless the other connection has been aborted.&lt;/P&gt;&lt;P&gt;But what if the cable is diconnected or the connection is lost?&lt;/P&gt;&lt;P&gt;How can I tell?&lt;/P&gt;&lt;P&gt;In my code example I am checking each time that the server on the other side is always the original to prevent some other location from stealing my connection.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;   while(socket_flag == TRUE)    {    sock2 = accept(listensock, &amp;amp;raddr, &amp;amp;addr_length);    return_error_if(sock2 == RTCS_SOCKET_ERROR);    if(addr.sin_addr.s_addr == raddr.sin_addr.s_addr)    {     shutdown(sock, FLAG_CLOSE_TX);     fclose(sockfd);     sockfd = fopen("socket:", (char_ptr)sock2);     socket_flag = TRUE;    }    else    {     diag_led_red();     RTCS_time_delay(100);     continue;    }    sock = accept(listensock, &amp;amp;addr, &amp;amp;addr_length);    return_error_if(sock == RTCS_SOCKET_ERROR);    if(addr.sin_addr.s_addr == raddr.sin_addr.s_addr)    {     shutdown(sock2, FLAG_CLOSE_TX);     fclose(sockfd);     sockfd = fopen("socket:", (char_ptr)sock);     socket_flag = TRUE;    }    else    {     diag_led_grn();     RTCS_time_delay(100);     continue;    }           }//while(socket_flag == TRUE)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:02:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-test-if-socket-connection-is-still-there/m-p/157980#M932</guid>
      <dc:creator>drummer</dc:creator>
      <dc:date>2020-10-29T09:02:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to test if socket connection is still there?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-test-if-socket-connection-is-still-there/m-p/157981#M933</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi drummer,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;I do not know&lt;/SPAN&gt; &lt;SPAN&gt;if this resolves&lt;/SPAN&gt; &lt;SPAN&gt;your case&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt; &lt;SPAN&gt;but you&lt;/SPAN&gt; &lt;SPAN&gt;can at least&lt;/SPAN&gt; &lt;SPAN&gt;know if the&lt;/SPAN&gt; &lt;SPAN&gt;ethernet cable&lt;/SPAN&gt; &lt;SPAN&gt;is connected&lt;/SPAN&gt; &lt;SPAN&gt;using&lt;/SPAN&gt; &lt;SPAN&gt;the function&lt;/SPAN&gt; &lt;SPAN&gt;ipcfg_get_link_active&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;Best Regards.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 May 2012 23:04:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-test-if-socket-connection-is-still-there/m-p/157981#M933</guid>
      <dc:creator>Tgomes</dc:creator>
      <dc:date>2012-05-03T23:04:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to test if socket connection is still there?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-test-if-socket-connection-is-still-there/m-p/157982#M934</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks for your input.&lt;/P&gt;&lt;P&gt;I tried several things:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;ipcfg_get_link_active(DEFAULT_ENET_DEVICE)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ipcfg_get_state(DEFAULT_ENET_DEVICE)&lt;/P&gt;&lt;P&gt;prior to initialization ipcfg_get_link_active returns 0&lt;/P&gt;&lt;P&gt;afterwords it returns 1 always.&lt;/P&gt;&lt;P&gt;ipcfg_get_state looked more promising because it returned 0,1,2,3 depending on its state but couldn't tell if I had disconnected.&lt;/P&gt;&lt;P&gt;One of&lt;BR /&gt;• IPCFG_STATE_INIT&lt;BR /&gt;• IPCFG_STATE_UNBOUND&lt;BR /&gt;• IPCFG_STATE_BUSY&lt;BR /&gt;• IPCFG_STATE_STATIC_IP&lt;BR /&gt;• IPCFG_STATE_DHCP_IP&lt;BR /&gt;• IPCFG_STATE_AUTO_IP&lt;BR /&gt;• IPCFG_STATE_DHCPAUTO_IP&lt;BR /&gt;• IPCFG_STATE_BOOT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 May 2012 02:10:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-test-if-socket-connection-is-still-there/m-p/157982#M934</guid>
      <dc:creator>drummer</dc:creator>
      <dc:date>2012-05-04T02:10:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to test if socket connection is still there?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-test-if-socket-connection-is-still-there/m-p/157983#M935</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;same issue here ..&lt;/P&gt;&lt;P&gt;.. some new ideas? =)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 May 2012 16:22:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-test-if-socket-connection-is-still-there/m-p/157983#M935</guid>
      <dc:creator>monXii</dc:creator>
      <dc:date>2012-05-07T16:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to test if socket connection is still there?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-test-if-socket-connection-is-still-there/m-p/157984#M936</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;Have you&lt;/SPAN&gt; &lt;SPAN&gt;checked the&lt;/SPAN&gt; &lt;SPAN&gt;hardware&lt;/SPAN&gt; &lt;SPAN&gt;connections&lt;/SPAN&gt;&lt;SPAN&gt;?&lt;/SPAN&gt; &lt;SPAN&gt;I ask this because&lt;/SPAN&gt; &lt;SPAN&gt;I had a problem&lt;/SPAN&gt; &lt;SPAN&gt;very similar to&lt;/SPAN&gt; &lt;SPAN&gt;this,&lt;/SPAN&gt; &lt;SPAN&gt;and the cause was&lt;/SPAN&gt; &lt;SPAN&gt;the&lt;/SPAN&gt; &lt;SPAN&gt;connection between&lt;/SPAN&gt; &lt;SPAN&gt;the connector and the&lt;/SPAN&gt; &lt;SPAN&gt;transceiver&lt;/SPAN&gt; &lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;DP83640&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt; &lt;SPAN&gt;Two&lt;/SPAN&gt; &lt;SPAN&gt;wires&lt;/SPAN&gt; &lt;SPAN&gt;were&lt;/SPAN&gt; &lt;SPAN&gt;reversed and&lt;/SPAN&gt; &lt;SPAN&gt;some resistors&lt;/SPAN&gt; &lt;SPAN&gt;in the wrong place&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;Best regards.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 May 2012 19:51:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-test-if-socket-connection-is-still-there/m-p/157984#M936</guid>
      <dc:creator>Tgomes</dc:creator>
      <dc:date>2012-05-08T19:51:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to test if socket connection is still there?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-test-if-socket-connection-is-still-there/m-p/157985#M937</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;mh.. can't believe that the wiring is incorrect ..&lt;/P&gt;&lt;P&gt;.. cause ethernet works fine! but only the cable detection ..&lt;/P&gt;&lt;P&gt;i'll try it on the tower ..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 May 2012 20:48:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-test-if-socket-connection-is-still-there/m-p/157985#M937</guid>
      <dc:creator>monXii</dc:creator>
      <dc:date>2012-05-22T20:48:39Z</dc:date>
    </item>
  </channel>
</rss>

