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.

CCS/CC3200-LAUNCHXL: UDP Socket example set source port

Part Number: CC3200-LAUNCHXL
Other Parts Discussed in Thread: CC3200

Tool/software: Code Composer Studio

Hi, i am using the UDP socket example to send data to cloud server i can set the destination ip and port, can i set the source port that sending data to server (cc3200 port)

sAddr.sin_port = sl_Htons((unsigned short)usPort);
sAddr.sin_addr.s_addr = sl_Htonl((unsigned int)g_ulDestinationIp);

  • hi jan Dospel ,

    Thanks for your response, i am trying to send rtp packets to a cloud server of port 10001 from my cc3200 port 8000 and i want to receive
    rtp data from server at cc3200 port 8000 but their is no data receiving i got stuck in sl_RecvFrom please check below code if any error

    char Rtp_data(char *buff)
    {
    short sTestBufLen;
    SlSockAddrIn_t sAddr1;
    SlSockAddrIn_t sAddr2;
    int iAddrSize;
    int iSockID1;
    short usPort= atoi(RTP_PORT);
    char Buffrc[1000];
    //filling the UDP server socket address
    sAddr1.sin_family = SL_AF_INET;
    sAddr1.sin_port = sl_Htons((unsigned short)10001);
    sAddr1.sin_addr.s_addr = sl_Htonl((unsigned int)g_ulDestinationIp);
    iAddrSize = sizeof(SlSockAddrIn_t);
    // creating a UDP socket

    if (( iSockID1 = sl_Socket(SL_AF_INET,SL_SOCK_DGRAM, 0)) < 0){
    UART_PRINT("error");
    }

    sAddr2.sin_family = SL_AF_INET;
    sAddr2.sin_port = sl_Htons((unsigned short)8000);
    sAddr2.sin_addr.s_addr = 0;

    if (sl_Bind(iSockID1, (SlSockAddr_t *)&sAddr2, iAddrSize) < 0) {
    UART_PRINT("errrrroooooorrrrrrr");
    }

    sTestBufLen = 172 ;

    sl_SendTo(iSockID1, buff, sTestBufLen, 0, (SlSockAddr_t *)&sAddr1, iAddrSize)


    sl_RecvFrom(iSockID1, Buffrc, sTestBufLen, 0,
    ( SlSockAddr_t *)&sAddr2, (SlSocklen_t*)&iAddrSize );

    Message(Buffrc);







    return 0;

    }
  • Hi,

    You should to read return codes from sl_ API calls. What do you means by got stuck in sl_RecvFrom?

    Jan
  • Hi,

    when debugging , waiting for data at sl_RecvFrom(iSockID1, Buffrc, sTestBufLen, 0( SlSockAddr_t *)&sAddr2, (SlSocklen_t*)&iAddrSize );

    but no data receiving at 8000 port of cc3200 is this an issue with the above configuration .
  • Hi,

    Are you sure that any data comes? Please use network sniffer to check it.

    Jan