SWRU368C May 2018 – January 2021 CC3100 , CC3100MOD , CC3200 , CC3200MOD
int CreateConnection(unsigned long DestinationIP)
{
int Status;
SlSockAddrIn_t Addr;
int AddrSize;
int SockID = 0;
SlTimeval_t timeval;
Addr.sin_family = SL_AF_INET;
Addr.sin_port = sl_Htons(443); // secured connection
Addr.sin_addr.s_addr = sl_Htonl(DestinationIP);
AddrSize = sizeof(SlSockAddrIn_t);
SockID = sl_Socket(SL_AF_INET,
SL_SOCK_STREAM,
SL_SEC_SOCKET);
if( SockID < 0 )
{
// error
while (1);
}
Sl_SetSockOpt(sockID,
SL_SOL_SOCKET,
SL_SO_SECURE_FILES_CA_FILE_NAME,
”rootCA.der”,
strlen(“rootCA.der”));
Status = sl_Connect(SockID,
( SlSockAddr_t *)&Addr,
AddrSize);
if( Status < 0 && Status != SL_ESECSNOVERIFY )
{
// error
while(1);
}
return SockID;
}