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.

sl_Send Fails Intermittently

Other Parts Discussed in Thread: CC3100

sl_Send appears to be failing intermittently for me. I've tried a few different TCP server test programs as well as my own, and they all have the same results. Sometimes the server receives the data sent by sl_Send, and sometimes it receives NULL. There doesn't appear to be any pattern to success or failure; but if I call the function twice in a row, the 2nd attempt seems to work most of the time. I've included my full function below. I'm using the CC3100, and it is successfully connecting to my WiFi network. sl_Socket and sl_Connect seem to be working, and the server side sees the new client connection each time. However, sl_Send fails about half the time. Sometimes it returns -1 on failure, and sometimes it returns 20 (the number of bytes I'm sending) on a failure. Any ideas or suggestions would be appreciated.

int sendToServer ()
{
	SlSockAddrIn_t  addr;
	int addrSize = sizeof(SlSockAddrIn_t);
	int sockID;
	char msgBuf[20] = "EventMsg,12345678,2\n";
	int status;

	addr.sin_family = SL_AF_INET;
	addr.sin_port = sl_Htons(9898);
	addr.sin_addr.s_addr = sl_Htonl(SL_IPV4_VAL(192,168,2,117));

	/* Open a TCP socket with the server and connect with it. */
	sockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);

	status = sl_Connect(sockID, (SlSockAddr_t *)&addr, addrSize);

	/* Send the message buffer to the server */
	status = sl_Send(sockID, &msgBuf, 20, 0 );

	/* Close the socket with the server */
	sl_Close(sockID);

	return status;
}

  • Hi Chad,

    I have tested the above function several times and it is not showing any failure. Which service pack and SDK version are you using?
    Can you please send a stream of 1000 packets from your application and check whether the remote device receives all of them?

    Regards,
    Raghavendra
  • I am using SDK 1.1.0. How do I tell which service pack I'm using?

    When I send 1000 packets, I'll receive 100% of them about half the time, and I'll receive 0% of them about half the time - never in between.

    sl_Send usually returns -1 on failure. What causes sl_Send to return -1 if sl_Socket and sl_Connect were both successful?

  • Hi Chad,

    Apologies for the delayed response.

    You can check the service by using the below code.

    _u8           configOpt = 0;
    _u8           configLen = 0;
    
    configOpt = SL_DEVICE_GENERAL_VERSION;
    configLen = sizeof(ver);
    retVal = sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION, &configOpt, &configLen, (_u8 *)(&ver));
    ASSERT_ON_ERROR(retVal);
    
    printf("Host Driver Version: %s\n",SL_DRIVER_VERSION);
    printf("Build Version %d.%d.%d.%d.31.%d.%d.%d.%d.%d.%d.%d.%d\n",
                         ver.NwpVersion[0],ver.NwpVersion[1],ver.NwpVersion[2],ver.NwpVersion[3],
                         ver.ChipFwAndPhyVersion.FwVersion[0],ver.ChipFwAndPhyVersion.FwVersion[1],
                         ver.ChipFwAndPhyVersion.FwVersion[2],ver.ChipFwAndPhyVersion.FwVersion[3],
                         ver.ChipFwAndPhyVersion.PhyVersion[0],ver.ChipFwAndPhyVersion.PhyVersion[1],
                         ver.ChipFwAndPhyVersion.PhyVersion[2],ver.ChipFwAndPhyVersion.PhyVersion[3]);

    • Can you please check the sl_Close() API return value?
    • When sl_Send() fails can please try resending the data on the same socket.

    Regards,

    Ankur

  • Hi Chad,

    I hope your issue is resolved.
    I am closing this thread, If the issue still exists please open a new thread and add a link to thread for reference.

    Regards,
    Ankur