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.

RTOS/DK-TM4C129X: TCP server connection got refused on multiple attempts

Part Number: DK-TM4C129X

Tool/software: TI-RTOS

Hi,

I am using the example(TCP Echo) provided in tirtos tivac-2.16.01.14 ,i am able to connect  the client  and able to send and receive messages in staticip configuration.After some time connection got disconnected and on next attempt  to connect ,its showing Connection refused by remote host in Winsock  tester.

(1.) How to Keep the Socket Alive for continuously.

(2.) Requirement is to make Server Connection open and client can connect and disconnect without resetting the TCP Server.

Please find the attached files for reference.

Thanks & Regards,

Arjunan

 7181.tcpEcho.cfg

  • Hi Arjunan,

    1) The example should run continuously unless an error occurs. Nothing extra needs to be done.

    There are several error conditions checked for inside tcpEcho.c. Can you see which of those your program is entering? Maybe by stepping through the code.

    If accept() fails, errno should be set. Can you check its value before your program exits?

     

    Best,

    Brandon

  • Thanks Brandon for replying,
    i am able to solve the issue using infinite loop.

    while(1)
    {

    if( (sock = accept(server, (struct sockaddr *)&clientAddr, &addrlen)) < 0)
    {

    System_printf("could not open a socket to accept data\n");
    }

    while ((bytesRcvd = recv(clientfd, buffer, TCPPACKETSIZE, 0)) > 0)
    {
    bytesSent = send(clientfd, buffer, bytesRcvd, 0);
    //...
    //...
    }

    close(sock);
    }

    regards,
    Arjunan