This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TCP/IP Connection



Hello everyone,

I use the TM4C1294XL-LaunchPad, and i have a quation about TCP/IP . How i can make the microcontroller listening all the time for a new tcp connection  ? In my Code i make a connection about TCP and after the kommuncation i close the connection about a command "CLOSE CONNECT", after that will be my microcontroller ready for a new connetcion, but i want, that my microcontroller watting all the time for a new connection, even during a communication, and even if i vorget to give a command "CLOSE CONNECT".

Sorry about my Englisch

Regards

Fares

  • Hi Fares,
    Please post your code around area "close connect" using post rich formatting (%) to begin. Sound like U need while loop waiting?
  • Hello BP101,

    I use this method to close my connection :

     
    //*****************************CLOSE CONNECTION*****************************************
     
    static void close_conn(struct tcp_pcb *pcb, struct TCPState *TCPstate)
    {
      tcp_arg(pcb, NULL);
      tcp_sent(pcb, NULL);
      tcp_recv(pcb, NULL);
     
      mem_free(TCPstate);
      tcp_close(pcb);
    }

    and than i coll this method in one another method, when the microcontroller gets the command "CLOSE_CONNECT!"  

    }else if(strcmp(data, "CLOSE_CONNECT!") == 0){
     
               struct TCPState * TCP_state;
               TCP_state = (struct TCPState *)mem_malloc(sizeof(struct TCPState));
               close_conn(pcb,TCP_state);
     
     
           }

    Thank you

    regards

    Fares

  • You could try some kind of while loop in your code above but to what end?

    Seems like you need a more robust TCP stack to be listening for incoming packets while your application is processing the previous packets from a ring buffer. TI down load Tivaware for TM4C1294 includes 3rd party TCP stack called LWIP v1.4.1 methods for complex communication schema. There are examples of code in many folders.

    LWIP has a RAW http server already built and TI wrote (Tiva-TM4c129.c) module in folder (.../lwip1.4.1/ports/tiva.../Netif) a low level driver for EMAC DMA descriptors ported into (Pbufs). Most all the work is done - Believe all have to do is build the package and write data to/from (ringbuf.c). Set or copy the Ethernet changes you desire in (lwipopts.h) and refer to (opt.h) for the Ethernet functions.