SWRU455M February 2017 – October 2020 CC3120 , CC3120MOD , CC3130 , CC3135 , CC3135MOD , CC3220MOD , CC3220MODA , CC3220R , CC3220S , CC3220SF , CC3230S , CC3230SF , CC3235MODAS , CC3235MODASF , CC3235MODS , CC3235MODSF , CC3235S , CC3235SF
_i16 Status, Sd;
_u16 nfds;
SlSockAddrIn_t Addr;
SlTimeval_t timeVal;
SlFdSet_t rxSet;
_i8 RecvBuf[1460];
timeVal.tv_sec = 0;
timeVal.tv_usec = 0;
//Open TCP client socket
Sd = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
if( Status )
{
// error
}
Addr.sin_family = SL_AF_INET;
Addr.sin_port = sl_Htons(5001);
Addr.sin_addr.s_addr = sl_Htonl(SL_IPV4_VAL(192,168,1,31));;
Status = sl_Connect(Sd, ( SlSockAddr_t *)&Addr, sizeof(SlSockAddr_t));
if( Status )
{
// error
}
Status = sl_Select( nfds, NULL, &rxSet, NULL, &timeVal );
//Sleep until triggered by the select event
//Call select again since the trigger event has arrived
SL_SOCKET_FD_ZERO( &rxSet );
SL_SOCKET_FD_SET( Sd, &rxSet );
Status = sl_Select( nfds, NULL, &rxSet, NULL, &timeVal );
if (SL_SOCKET_FD_ISSET(Sd, &rxSet))
{
//socket is marked, call receive
Status = sl_Recv(Sd, RecvBuf, 1460, 0);
if( Status )
{
// error
}
}