Part Number: LAUNCHCC3220MODASF
Other Parts Discussed in Thread: CC3200
Implementing a client socket connection
I have found an example, but I don't think I am putting the Server IP (Gateway) address ( C0A83101 or 192.168.49.1 ) in the sAddr structure correctly.
processors.wiki.ti.com/.../CC32xx_TCP_Socket_Application_0.5.2
The error that is returned is a -111, connection refused, as seen from my console below
[NETAPP EVENT] IP set to: IPv4=192.168.49.113 , Gateway=192.168.49.1
user:
[p2pstart] : P2p Connected, Starting Socket connection
[p2pstart] : Client Connection sl_Socket()
[p2pstart] : Client Connection sl_Connect()
[p2pstart] : C0A83101
[p2pstart] : sl_Connect()[line:1734, error:-111] Socket error, please refer "SOCKET ERRORS CODES" section in errors.h
Here is my implementation of the client socket connect
// Open a socket with standard parameters
UART_PRINT("\n\r[p2pstart] : Client Connection sl_Socket()\n\r");
newsock = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
if( newsock < 0 )
{
// error
UART_PRINT("[p2pstart] : sl_Socket()[line:%d, error:%d] %s\n\r", __LINE__, status, SL_SOCKET_ERROR);
return -1;
}
//Connect to the server IP and port number
UART_PRINT("\n\r[p2pstart] : Client Connection sl_Connect() \n\r");
UART_PRINT("\n\r[p2pstart] : %X \n\r", sAddr.in4.sin_addr.s_addr);
status = sl_Connect(newsock, csa, addrSize );
if( status < 0 )
{
// error
UART_PRINT("[p2pstart] : sl_Connect()[line:%d, error:%d] %s\n\r", __LINE__, status, SL_SOCKET_ERROR);
sl_Close(newsock);
return -1;
}
Here is my attempt to write the IP address to the sAddr structure that is pointed to by the csa pointer
/* filling the TCP server socket address */
sAddr.in4.sin_family = SL_AF_INET;
/* Set the server's port: We'll receive connection requests on this port */
sAddr.in4.sin_port = sl_Htons((unsigned short)portNumber); // 5001
// sAddr.in4.sin_addr.s_addr = SL_INADDR_ANY;
sAddr.in4.sin_addr.s_addr = app_CB.CON_CB.GatewayIP; //C0A83101 or 192.168.49.1
sa = (SlSockAddr_t*)&sAddr.in4;
csa = (SlSockAddr_t*)&sAddr.in4;
addrSize = sizeof(SlSockAddrIn_t);