AnsweredAssumed Answered

LWIP K64: Issue with TCP and UDP server on the same time with different port.

Question asked by Mikael Elharrar on Aug 30, 2017
Latest reply on Sep 1, 2017 by Johann Zimmermann

Hi ,

I'm using for my project the base code of the FRDM2.1 SDK with HTTPServer and FreeRTOS (lwip + freeRtos).

I enabled DHCP functionality and I added to my project, a UDP server in order to discover the device with UDP broadcast request in case the device got its IP address dynamically.


My problem is now the HTTP server doesn't work anymore ( it doesn't get the HTTP get request ).

When I disable my UDP server thread, HTTP server works, and if I enable the UDP server, HTTP server is unreachable.

I don't know if the UDP server is working because my UDP client is under development.

Note that I initialize the UDP server thread before the HTTP server.


Below my UDP server code (if needed).

I use the socket API .


    int socket_fd;
    struct sockaddr_in sa,ra;


    int recv_data;
    char data_buffer[256];
    uint8_t socket_ok = 0;
    uint8_t failed_cnt = 0;




        /* Creates an UDP socket (SOCK_DGRAM) with Internet Protocol Family (PF_INET).
         * Protocol family and Address family related. For example PF_INET Protocol Family and AF_INET family are coupled.
        socket_fd = socket(PF_INET, SOCK_DGRAM, 0);
        if ( socket_fd < 0 ){
            PRINTF("[DISCOVERY_TASK]: socket call failed.\n\r");
            socket_ok = 0;
            socket_ok = 1;
            failed_cnt = 0;


        /* RECEIVER_PORT_NUM is port on which Server waits for data to
         * come in. It copies the received data into receive buffer and
         * prints the received data as string. If no data is available it
         * blocks.recv calls typically return any available data on the socket instead of waiting for the entire data to come.
         * */
            recv_data = recv(socket_fd,data_buffer,sizeof(data_buffer),0);
            if(recv_data > 0){


                PRINTF("[DISCOVERY_TASK]: Received %s bytes\n\r", recv_data);


                _handle_discovery_request(data_buffer, recv_data, socket_fd);
            else if(recv_data <= 0){


                PRINTF("[DISCOVERY_TASK]: Error: recv returned %d.\n\r", recv_data);
                socket_ok = 0;