main.c
int BsdTcpClient(unsigned short usPort)
{
    int             iCounter;

    SlSockAddrIn_t  sAddr;
    int             iAddrSize;
    int             iSockID;
    int             iStatus;

    long            lNonBlocking = 1;

    // filling the buffer
    for (iCounter=0 ; iCounter<BUF_SIZE ; iCounter++)
    {
        g_cBsdBuf[iCounter] = (char)(iCounter % 10);
    }

    //filling the TCP server socket address
    sAddr.sin_family = SL_AF_INET;
    sAddr.sin_port = sl_Htons((unsigned short)usPort);
    sAddr.sin_addr.s_addr = sl_Htonl((unsigned int)g_ulGatewayIP);

    iAddrSize = sizeof(SlSockAddrIn_t);

    // creating a TCP socket
    iSockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
    if( iSockID < 0 )
    {
        ASSERT_ON_ERROR(SOCKET_CREATE_ERROR);
    }

    // connecting to TCP server
    iStatus = sl_Connect(iSockID, ( SlSockAddr_t *)&sAddr, iAddrSize);
    if( iStatus < 0 )
    {
        // error
        sl_Close(iSockID);
        ASSERT_ON_ERROR(CONNECT_ERROR);
    }

    g_sockID = iSockID;

    //set to non-blocking
    iStatus = sl_SetSockOpt(iSockID, SL_SOL_SOCKET, SL_SO_NONBLOCKING,
                                &lNonBlocking, sizeof(lNonBlocking));
    if( iStatus < 0 )
    {
         sl_Close(iSockID);
         ASSERT_ON_ERROR(SOCKET_OPT_ERROR);
    }


    return SUCCESS;
}
//****************************************************************************
//
//! \brief Opening a TCP client side socket and sending data
//!
//! This function opens a TCP socket and tries to connect to a Server IP_ADDR
//!    waiting on port PORT_NUM.
//!    If the socket connection is successful then the function will send 1000
//! TCP packets to the server.
//!
//! \param[in]      port number on which the server will be listening on
//!
//! \return    0 on success, -1 on Error.
//
//****************************************************************************

\brief Opening a TCP client side socket and sending data
This function opens a TCP socket and tries to connect to a Server IP_ADDR
waiting on port PORT_NUM.
If the socket connection is successful then the function will send 1000
TCP packets to the server.

\param[in]      port number on which the server will be listening on

\return    0 on success, -1 on Error.
\ brief Opening a TCP client side socket and sending data This function opens a TCP socket and tries to connect to a Server IP_ADDR waiting on port PORT_NUM . If the socket connection is successful then the function will send 1000 TCP packets to the server . \ param [ in ] port number on which the server will be listening on \ return 0 on success - 1 on Error .
int BsdTcpClient(unsigned short usPort)
{
    int             iCounter;
    SlSockAddrIn_t  sAddr;
    int             iAddrSize;
    int             iSockID;
    int             iStatus;
    long            lNonBlocking = 1;
    for (iCounter=0 ; iCounter<BUF_SIZE ; iCounter++)
    {
        g_cBsdBuf[iCounter] = (char)(iCounter % 10);
    }
    sAddr.sin_family = SL_AF_INET;
    sAddr.sin_port = sl_Htons((unsigned short)usPort);
    sAddr.sin_addr.s_addr = sl_Htonl((unsigned int)g_ulGatewayIP);
    iAddrSize = sizeof(SlSockAddrIn_t);
    iSockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
    if( iSockID < 0 )
    {
        ASSERT_ON_ERROR(SOCKET_CREATE_ERROR);
    }
    iStatus = sl_Connect(iSockID, ( SlSockAddr_t *)&sAddr, iAddrSize);
    if( iStatus < 0 )
    {
        sl_Close(iSockID);
        ASSERT_ON_ERROR(CONNECT_ERROR);
    }
    g_sockID = iSockID;
    iStatus = sl_SetSockOpt(iSockID, SL_SOL_SOCKET, SL_SO_NONBLOCKING,
                                &lNonBlocking, sizeof(lNonBlocking));
    if( iStatus < 0 )
    {
         sl_Close(iSockID);
         ASSERT_ON_ERROR(SOCKET_OPT_ERROR);
    }
    return SUCCESS;
}
int BsdTcpClient ( unsigned short usPort ) { int iCounter ; SlSockAddrIn_t sAddr ; int iAddrSize ; int iSockID ; int iStatus ; long lNonBlocking = 1 ; for ( iCounter = 0 ; iCounter < BUF_SIZE ; iCounter ++ ) { g_cBsdBuf [ iCounter ] = ( char ) ( iCounter % 10 ) ; } sAddr . sin_family = SL_AF_INET ; sAddr . sin_port = sl_Htons ( ( unsigned short ) usPort ) ; sAddr . sin_addr . s_addr = sl_Htonl ( ( unsigned int ) g_ulGatewayIP ) ; iAddrSize = sizeof ( SlSockAddrIn_t ) ; iSockID = sl_Socket ( SL_AF_INET , SL_SOCK_STREAM , 0 ) ; if ( iSockID < 0 ) { ASSERT_ON_ERROR ( SOCKET_CREATE_ERROR ) ; } iStatus = sl_Connect ( iSockID , ( SlSockAddr_t * ) & sAddr , iAddrSize ) ; if ( iStatus < 0 ) { sl_Close ( iSockID ) ; ASSERT_ON_ERROR ( CONNECT_ERROR ) ; } g_sockID = iSockID ; iStatus = sl_SetSockOpt ( iSockID , SL_SOL_SOCKET , SL_SO_NONBLOCKING , & lNonBlocking , sizeof ( lNonBlocking ) ) ; if ( iStatus < 0 ) { sl_Close ( iSockID ) ; ASSERT_ON_ERROR ( SOCKET_OPT_ERROR ) ; } return SUCCESS ; }
\brief Opening a TCP client side socket and sending data
This function opens a TCP socket and tries to connect to a Server IP_ADDR
waiting on port PORT_NUM.
\ brief Opening a TCP client side socket and sending data This function opens a TCP socket and tries to connect to a Server IP_ADDR waiting on port PORT_NUM .
// filling the buffer
 //filling the TCP server socket address
 // creating a TCP socket
 // connecting to TCP server
 // error
 //set to non-blocking
