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.

CC3120: Simplelink sl_socket function

Part Number: CC3120


Hi,

I'm having trouble with the sl_socket function. if I close the socket and then reopen the socket again it increment sthe socket by one each time.

snippet of code below:

_i16 Status, Sd;

SlSockAddrIn_t Addr;

Addr.sin_family = SL_AF_INET;

Addr.sin_port = sl_Htons(1883);
Addr.sin_addr.s_addr = sl_Htonl(SL_IPV4_VAL(192,168,0,53));

Sd = sl_Socket(SL_AF_INET, SL_SOCK_STREAM, 0);

Status = sl_Connect(Sd, ( SlSockAddr_t *)&Addr, sizeof(SlSockAddrIn_t));

Status = sl_Send(Sd, data, i, 0 );

Status = sl_Close(Sd);

Regards,

             Liam

  • Hi Liam,

    Can you elaborate further what you mean by it is incrementing the socket by one each time? What exactly is incrementing?

    Also, are you basing your code off of an example? If so, which example and SDK are you using?

    Best regards,
    Kristen
  • Hi Kristen,

    He want to say that socket handle is increasing, which is pretty normal in this kind of usage.

    Jan
  • Hi,

    As Jan has mention the socket handler is incrementing when the socket is closed. Sd is what is used in the example I posted. If this is normal then I happy enough, i just thought after closing the socket the socket handler should remain at zero.

    If the server connection with the server drops for some reason, is it normal to have to close the socket and then enable it again to re-establish the connection? Can sl_connect not just be used if the connection drops?

    Thanks,

                   Liam