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.
Tool/software: Code Composer Studio
I am exchanging data packets between two CC3220 boards using TCP through WiFi in a local network. the code works fine and I exchange the data correctly when I send and receive 1460 bytes and if I increased the data length above the 1460 bytes, it receives zeros then the correct data then zeros and so on.
Questions:
1. Is the router the cause of this issue as it limits the no. of bytes sent and received due to its speed?
2. if not, so why does this problem happen?
P.S. both boards are connected locally to an ADSL router
P.S. when I tried to make both of them communicate through the internet, one launchpad to the ADSL router and the other to a mobile's hotspot, the same issue happened and when I reduced the data length to 1300, it worked fine without receiving NULL
you can find the code below:
Server:
PacketSocket= sl_Socket(SL_AF_INET, SL_SOCK_STREAM, 0); if ( 0 > PacketSocket) { UART_PRINT("error creating the socket"); } SockSettings.sin_family = SL_AF_INET; SockSettings.sin_port = sl_Htons(1040); SockSettings.sin_addr.s_addr = sl_Htonl(SocketServerIpAddr); Return= sl_SetSockOpt(PacketSocket,SL_SOL_SOCKET,SL_SO_NONBLOCKING,(_u8*)&BlockingOption,sizeof(BlockingOption)); if (Return < 0) { UART_PRINT("\n\r error starting sss 1\n\r"); } Status = sl_Bind(PacketSocket, ( SlSockAddr_t *)&SockSettings, sizeof(SlSockAddrIn_t)); if (!Status) { UART_PRINT("no error bind"); Status = sl_Listen(PacketSocket, 1); } else { UART_PRINT("there is an error binding"); } if (!Status) { UART_PRINT("no error listening"); } RetreivedConnectedSocket= SL_ERROR_BSD_EAGAIN; // // while ( 0 > RetreivedConnectedSocket ) { RetreivedConnectedSocket= sl_Accept(PacketSocket, ( SlSockAddr_t *)&WiFi_Config.SockSettings, (SlSocklen_t*)&AddrSize); if (RetreivedConnectedSocket < 0) { if(RetreivedConnectedSocket==SL_ERROR_BSD_EAGAIN) { sleep(1); }; UART_PRINT("noo connection\n\r"); } } Return= sl_SetSockOpt(RetreivedConnectedSocket,SL_SOL_SOCKET,SL_SO_NONBLOCKING,(_u8*)&BlockingOption,sizeof(BlockingOption)); if (Return < 0) { UART_PRINT("\n\r error starting sss 2\n\r"); }
while (1)
{ RxStatus = sl_Recv(RetreivedConnectedSocket, DataReceived, 1460, 0 ); TxStatus = sl_Send(RetreivedConnectedSocket, DataSent, 1460, 0);
}
the client:
PacketSocket= sl_Socket(SL_AF_INET, SL_SOCK_STREAM, 0); if ( 0 >PacketSocket) { UART_PRINT("error creating the socket"); } SockSettings.sin_family = SL_AF_INET; SockSettings.sin_port = sl_Htons(1040); SockSettings.sin_addr.s_addr = sl_Htonl(SocketServerIpAddr); Return= sl_SetSockOpt(PacketSocket,SL_SOL_SOCKET,SL_SO_NONBLOCKING,(_u8*)&BlockingOption,sizeof(BlockingOption)); if (Return < 0) { UART_PRINT("\n\r error starting sss 1\n\r"); } Status = SL_ERROR_BSD_EALREADY; while ( 0 > Status ) { Status= sl_Connect(PacketSocket, ( SlSockAddr_t *)&SockSettings, sizeof(SlSockAddrIn_t)<0); if (Status < 0) { UART_PRINT("error connect and will try again"); } }
while (1)
{ TxStatus = sl_Send(PacketSocket, DataSent, 1460 , 0 ); RxStatus= sl_Recv(PacketSocket, DataReceived, 1460, 0);
}
This is not the cause of my issue. I am already calling both send and receive in a while loop and I am not interested in stopping the code flow and execution to make sure that sending and receiving happened correctly as I am always sending and receiving. So, this is not the solution to my problem as I can see a very strange behaviour happens when I increase the data length to be more than 1460 through the local network and 1300 through the Internet.