<?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: FRDM-K64 as CLIENT use tcp_connect() to connect to remote server in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-K64-as-CLIENT-use-tcp-connect-to-connect-to-remote-server/m-p/1181557#M58796</link>
    <description>&lt;P&gt;P.S.&amp;nbsp;&lt;/P&gt;&lt;P&gt;And best of all, I am able to run BOTH webserver as well as client connection (2 sockets) in bare-metal (no RTOS) on this single FRDM-K64.&amp;nbsp; There was a slight delay in the website, most probably due to the tons and tons of PRINTF Terraterm console debug displays via UART-OpenSDA line that I have coded in to trace the code on my development PC, which is besides the WireShark sniffer on the spare PC that I use as "server" node.&lt;/P&gt;&lt;P&gt;I'll be programming data transfer callback application functions as CLIENT to send data to the PC node next, which eventual target will be a website in the cloud as server receiver.&lt;/P&gt;</description>
    <pubDate>Wed, 11 Nov 2020 15:18:17 GMT</pubDate>
    <dc:creator>mignacio</dc:creator>
    <dc:date>2020-11-11T15:18:17Z</dc:date>
    <item>
      <title>FRDM-K64 as CLIENT use tcp_connect() to connect to remote server</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-K64-as-CLIENT-use-tcp-connect-to-connect-to-remote-server/m-p/1179626#M58761</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have used the the base SDK project, proj_lwiphttpsrv_bm, which configures the FRDM-K64 as a Web server and that all works fine,&amp;nbsp;where my PC setup as specified IP address acts as the client with browser to GET the&amp;nbsp;default index.html webpage on its browser. &amp;nbsp;I have even modified the webpage to display something other than the default index.html.&lt;/P&gt;&lt;P&gt;Now as&amp;nbsp;the subject line says,&amp;nbsp;I have started programming the FRDM-K64 as a TCP client that will start a TCP raw "socket" by using tcp_new_ip_type() and then establish a connection to remote node using tcp_connect() to send SYN out to target "server" - by 3-way SYN-SYN/ACK-ACK handshake.&lt;/P&gt;&lt;P&gt;PROBLEM:&amp;nbsp; the FRDM client is not getting any ACK or SYN/ACK reply to the SYN it sends out to the target IP address I specified on PCB and put as input argument to tcp_connect().&amp;nbsp;&amp;nbsp; I see the SYN traveling over the ethernet line as captured on Wireshark from FRDM-K64 (IP: 192.168.0.102) sent to PC (IP: 192.168.0.100) but the PC just keeps sending out BROWSER and NBNS packets&amp;nbsp;as multicast(?) IP: 192.168.0.255 but NO clearcut SYN-ACK to the FRDM's SYN.&lt;/P&gt;&lt;P&gt;OTHER ISSUES:&amp;nbsp; I'm not sure I understand what I'm supposed to put in the function "tcp_connected()" callback function also specified as input argument to tcp_connect().&amp;nbsp;&amp;nbsp; Based on readings, I deduced it will be called back only AFTER the SYN-SYNACK-ACK 3-way handshake is complete, when connection has been established, just as I have observed in Wireshark monitoring for server mode of the FRDM-K64.&lt;/P&gt;&lt;P&gt;QUESTIONS:&amp;nbsp;&lt;/P&gt;&lt;P&gt;What am I missing to do in setting up FRDM-K64 as a client in RAW mode bare-metal?&lt;/P&gt;&lt;P&gt;I mean, I don't have to do any bind() or listen() or accept() operations, do I?&lt;/P&gt;&lt;P&gt;All I currently do for setup is to call tcp_new_ip_type(IPADDR_TYPE_V4) - should I use TYPE_ANY? - to get a new pcb and if successful, I call tcp_setprio() and setup callback function for connected.&lt;/P&gt;&lt;P&gt;Then pass the created pcb to tcp_connect() together with the target/remote IP address as this:&lt;/P&gt;&lt;P&gt;tcp_connect(pcb,netif_ip4_gw(netif), LWIP_IANA_PORT_HTTP,tcp_connected);&lt;/P&gt;&lt;P&gt;NOTE: I setup port as "http" = 80, webserver.&lt;/P&gt;&lt;P&gt;Basically, I let the FRDM-K64 initialize as regular web server mode, setup its ipaddr, mask, gw IP addresses in netif structure,... let it do all regular init function calls based on original SDK.&lt;/P&gt;&lt;P&gt;I don't right away do the tcp_connect right there.&amp;nbsp;&amp;nbsp; Instead, I let the network come-up, then inside ip4_input() I parse for incoming IP addresses.&amp;nbsp;&amp;nbsp; When I see the target address is the same as incoming source, that's when I do the tcp_connect() call.&lt;/P&gt;&lt;P&gt;And so, the SYN goes out and is received by the other side (PC) but how come the PC is not sending back ACK to the SYN?&amp;nbsp; as I can see on Wireshark monitor.&lt;/P&gt;&lt;P&gt;So I figured maybe the switch will make a difference and hooked-up cables so all nodes are in a star networked via a switch.&amp;nbsp; Nope.&lt;/P&gt;&lt;P&gt;So maybe because I don't have a PC app running as a server that is "listening" so I decided to connect to &lt;A href="http://www.google.com" target="_blank" rel="noopener"&gt;www.google.com&lt;/A&gt;, thinking that's a webserver somewhere there so I used google.com IP address.&amp;nbsp;&amp;nbsp; I see the SYN went out there in the www-land with IP address to google.com but still NO ACK from google.com.&amp;nbsp; I would think google.com is ALWAYS running as a "server" listening for client connection to it.&amp;nbsp; Why do these "servers" ignore my FRDM-K64's SYN to connect to their TCP layer at least and complete the 3-way handshake?&lt;/P&gt;&lt;P&gt;So what is wrong or is missing in my code?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it where I make the call to connect?&lt;/P&gt;&lt;P&gt;Do I have to broadcast/announce the FRDM-K64 node out there before trying out tcp_connect() so "listening" server can ACK to it?&lt;/P&gt;&lt;P&gt;Thanks for the help.&lt;/P&gt;&lt;P&gt;MI&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 17:15:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-K64-as-CLIENT-use-tcp-connect-to-connect-to-remote-server/m-p/1179626#M58761</guid>
      <dc:creator>mignacio</dc:creator>
      <dc:date>2020-11-09T17:15:12Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM-K64 as CLIENT use tcp_connect() to connect to remote server</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-K64-as-CLIENT-use-tcp-connect-to-connect-to-remote-server/m-p/1181046#M58779</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I posted my question on WireShart forum and with someone's suggestion for a "listerner" app on PC side,&amp;nbsp; the mind started grinding gears and this is what I did which solved my problem;&amp;nbsp; hopefully it helps someone.&lt;/P&gt;&lt;P&gt;&lt;A href="https://ask.wireshark.org/question/19902/no-server-reply-to-client-syn-tcp-connection-request/" target="_blank"&gt;https://ask.wireshark.org/question/19902/no-server-reply-to-client-syn-tcp-connection-request/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I finally got to establish a 3-way handshake connection with FRDM-K64 as client initiating SYN packet and the PC as server ACK-ing back with SYN-ACK packet and FRDM reply with ACK. So connection state is ESTABLISHED.&lt;/P&gt;&lt;P&gt;After reading through some more suggestions on how to listen, I just ended-up using simple Windows cmd line "netstate -a". There I saw the target PC's IP address:port in "LISTENING" state. It so happen its IP:139. So I replaced port "80" (http) with "139" and voila! the PC port sent back an SYN-ACK and all things went well from there.&lt;/P&gt;&lt;P&gt;Now I have a connection to send out data to from the FRDM board.&lt;/P&gt;&lt;P&gt;I note that port 139 is a port for SMP protocol that enables inter-process communication. The server sent back RST-ACK in a few seconds because my FRDM board's program has not done any "upper-layer" data transfer application at this point which is what I will be doing next. If anyone has any suggestion on any PC application I can run that is binded to port 139 which my data transfer application (e.g. display "hello world" at first on server side), please let me know.&lt;/P&gt;&lt;P&gt;Also, if I have time, I'll see what the effect of this if I disable/remove the "window scaling", "multiplier" and "SACK permitted" TCP header options and just keep it as original just "MSS" option on the SYN packet. Any comments?&lt;/P&gt;&lt;P&gt;I hope this solution will help others who have struggled with establishing a TCP connection with 3-way handshaking at client initiation.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2020 22:43:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-K64-as-CLIENT-use-tcp-connect-to-connect-to-remote-server/m-p/1181046#M58779</guid>
      <dc:creator>mignacio</dc:creator>
      <dc:date>2020-11-10T22:43:44Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM-K64 as CLIENT use tcp_connect() to connect to remote server</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-K64-as-CLIENT-use-tcp-connect-to-connect-to-remote-server/m-p/1181557#M58796</link>
      <description>&lt;P&gt;P.S.&amp;nbsp;&lt;/P&gt;&lt;P&gt;And best of all, I am able to run BOTH webserver as well as client connection (2 sockets) in bare-metal (no RTOS) on this single FRDM-K64.&amp;nbsp; There was a slight delay in the website, most probably due to the tons and tons of PRINTF Terraterm console debug displays via UART-OpenSDA line that I have coded in to trace the code on my development PC, which is besides the WireShark sniffer on the spare PC that I use as "server" node.&lt;/P&gt;&lt;P&gt;I'll be programming data transfer callback application functions as CLIENT to send data to the PC node next, which eventual target will be a website in the cloud as server receiver.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2020 15:18:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-K64-as-CLIENT-use-tcp-connect-to-connect-to-remote-server/m-p/1181557#M58796</guid>
      <dc:creator>mignacio</dc:creator>
      <dc:date>2020-11-11T15:18:17Z</dc:date>
    </item>
  </channel>
</rss>

