AnsweredAssumed Answered

F-NET on K60n512 send() Function Error

Question asked by seungback jung on Aug 2, 2013
Latest reply on Aug 21, 2013 by Hui_Ma

Dear all.

I am porting F-NET 2.5 on K60n512 without RTOS.(Only Firmware.)

Then I succesed UDP Send message to Server(PC) . (10 times)

However I changed the protocol  to TCP from UDP .

And send the data to server with 10 times

But server didn't receive the data.......

Just, Server received first data.

and when, Client(Kinetis K60N) was closed() socket. server received other dataa(9 datas),

Where I check on source code????

PLS Help me.

 

This code is based democode is as follow.

 

All configuration is default.

////////////////code. ////////////////////////

        /* Create socket */

        if((fapp_bench.socket_foreign = socket(AF_INET, SOCK_STREAM, 0)) == SOCKET_INVALID)

        {

              goto ERROR_1;

        }

       

        /* Set Socket options. */

        if( /* Setup linger option. */

            (setsockopt (fapp_bench.socket_foreign, SOL_SOCKET, SO_LINGER, (char *)&linger_option, sizeof(linger_option)) == SOCKET_ERROR) ||

            /* Set socket buffer size. */

            (setsockopt(fapp_bench.socket_foreign, SOL_SOCKET, SO_RCVBUF, (char *) &bufsize_option, sizeof(bufsize_option))== SOCKET_ERROR) ||

            (setsockopt(fapp_bench.socket_foreign, SOL_SOCKET, SO_SNDBUF, (char *) &bufsize_option, sizeof(bufsize_option))== SOCKET_ERROR) ||

            /* Enable keepalive_option option. */

            (setsockopt (fapp_bench.socket_foreign, SOL_SOCKET, SO_KEEPALIVE, (char *)&keepalive_option, sizeof(keepalive_option)) == SOCKET_ERROR) ||

            /* Keepalive probe retransmit limit. */

            (setsockopt (fapp_bench.socket_foreign, IPPROTO_TCP, TCP_KEEPCNT, (char *)&keepcnt_option, sizeof(keepcnt_option)) == SOCKET_ERROR) ||

            /* Keepalive retransmit interval.*/

            (setsockopt (fapp_bench.socket_foreign, IPPROTO_TCP, TCP_KEEPINTVL, (char *)&keepintvl_option, sizeof(keepintvl_option)) == SOCKET_ERROR) ||

            /* Time between keepalive probes.*/

            (setsockopt (fapp_bench.socket_foreign, IPPROTO_TCP, TCP_KEEPIDLE, (char *)&keepidle_option, sizeof(keepidle_option)) == SOCKET_ERROR)

        )

      

        /* Connect to the server.*/

        fnet_memset(&foreign_addr, 0, sizeof(foreign_addr));

        foreign_addr.sin_addr.s_addr = SERVER_ADDR;;

        foreign_addr.sin_port = SERVER_PORT;   

        foreign_addr.sin_family = AF_INET;

       

        connect(fapp_bench.socket_foreign, (struct sockaddr *)(&foreign_addr), sizeof(foreign_addr));

       do

        {

            option_len = sizeof(connection_state);

            getsockopt(fapp_bench.socket_foreign, SOL_SOCKET, SO_STATE, (char*)&connection_state, &option_len);

        }

        while (connection_state == SS_CONNECTING);

       

        if(connection_state != SS_CONNECTED)

        {

           goto ERROR_2;

        }

       

        for(i=0;i<10;i++)

        {

            send_result = send( fapp_bench.socket_foreign, (char*)test_data, 1030, 0);   //10 times send.

          }          

Outcomes