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.

Settting Port address(Basic Wi-fi application)

Hi,

I am trying to use UDP to communicate with the cc3000. I am making  a server UDP socket on the CC3000.

For this my code is:

ulSocket = socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP).

As I understand you need to perform a bind operation on this socket to bind the server port to it.

For this the code is bind(ulSocket,?,?). My question is what 2 parameters do I enter. The function description says that you should enter a const sockaddr *addr, INT32 addrlen . Suppose I am trying to bind port number 9876 to this socket what do I enter here?

Thanks & regards,

Raven

  • Hi Raven,

    sorry, I have no example by hand to quote here.

    Please use the E2E search function (on top of the threads) and e.g. search for "CC3000 bind" (or even some more or other keywords).

    You will find examples and question, where you see how other have used this.

    Best regards,

    Martin

  • Here is an extract of a HTTP TCP server I have. Bind is used the same. HTTP_PORT should be replaced with your port. I suggest you checkout Beej's guide to network programming: http://beej.us/guide/bgnet/ TI's sockets follow the examples close enough in most cases.
        sockaddr_in serverAddr = {0};
        serverAddr.sin_family = AF_INET;
        serverAddr.sin_port = htons(HTTP_PORT);
       
        /* ... */
    
        else if (bind(serverSocket, (sockaddr *)&serverAddr,
                      sizeof(serverAddr)) == -1)
        {
            /* error */
        }