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.

ERROR SL_ECONNREFUSED (-111)

Other Parts Discussed in Thread: CC3200

Hello,

in my application I use the following part of my code:

#define IP_ADDR             0xc0a83E0A /*0xc0a83E0A- 192.168.62.10 */

void SetTCPClient(unsigned short usPort)
{
    SlSockAddrIn_t  sAddr;
    int             iSockID;
    int             iStatus;

    unsigned char ucVal = 1;
    long lRetVal = -1;
    unsigned long  g_ulDestinationIp = IP_ADDR;

/* Filling the TCP server socket address                                                                            */
    sAddr.sin_family = SL_AF_INET;
    sAddr.sin_port = sl_Htons((unsigned short)usPort);
    sAddr.sin_addr.s_addr = sl_Htonl((unsigned int)g_ulDestinationIp);

    lRetVal = sl_NetCfgSet(SL_IPV4_STA_P2P_CL_DHCP_ENABLE,1,1,&ucVal);
    if(lRetVal<0)
    {
        UART_PRINT("[ERROR] Can't set network parameters.\n\r");
    }


/* Creating TCP Socket                                                                                                */
    iSockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
    if(iSockID<0)
    {
        switch (iSockID)
        {
               case SL_ENSOCK:
                   UART_PRINT("[ERROR] Exceeded maximal number of socket.\n\r"); break;
               case SL_ENOMEM:
                   UART_PRINT("[ERROR] Memory allocation error.\n\r"); break;
               case SL_EACCES:
                   UART_PRINT("[ERROR] Permission denied.\n\r"); break;
               case SL_EINVAL:
                   UART_PRINT("[ERROR] Error in socket configuration.\n\r"); break;
               case SL_EPROTOTYPE:
                   UART_PRINT("[ERROR] Illegal type parameter.\n\r"); break;
               case SL_EPROTONOSUPPORT:
                   UART_PRINT("[ERROR] Illegal protocol parameter.\n\r"); break;
               case SL_EOPNOTSUPP:
                   UART_PRINT("[ERROR] Illegal combination of protocol and type parameters.\n\r"); break;
               case SL_EAFNOSUPPORT:
                   UART_PRINT("[ERROR] illegal domain parameter.\n\r"); break;
               default:
                   UART_PRINT("[ERROR] Resources allocation error.\n\r"); break;
        }
    }

/* Connecting to TCP server                                                                                            */
    iStatus = sl_Connect(iSockID, ( SlSockAddr_t *)&sAddr, sizeof(SlSockAddrIn_t));
    if(iStatus<0)
    {
        switch (iStatus)
        {
               case SL_EALREADY:
                   UART_PRINT("[ERROR] Non blocking connect in progress, try again.\n\r"); break;
               case SL_POOL_IS_EMPTY:
                   UART_PRINT("[ERROR] There are no resources in the system, try later.\n\r"); break;
               default:
                   UART_PRINT("[ERROR] TCP Connect.\n\r"); break;
        }
      sl_Close(iSockID);
    }
}

when I call sl_Connect(...), the variable iStatus become -111, which mean Connection refused. What am I missing in my SetTCPClient function to establish connection between CC3200 and server with IP_ADDR IP address (server listen on port 3000,usPort = 3000). Thanks in advice.

Best regards,

Sergey Mihaylov.