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; }