Cloud COAP-Client TCP Issues

I'm building a COAP client using the Nordic nRF9160DK cloud coap-client example code as my base. I have the UDP version working great. But I'd like to convert to TCP.. I was hoping it would be a simple change to the socket just the addrinfo and socket creation calls, and turning off polling (since it's stream oriented) The first packet appears to send successfully. And the 2nd attempt always fails with a -128 error. I know COAP is more adapted to packet vs stream protocols. But I believe it is designed to work with either. Can you assist with resolving this issue. I will post some screenshots to show the mods I made for TCP.

Parents Reply
  • Well, for some reason, I can't drag-n-drop the screenshots here. So I'll just paste the code. Ugh!

    int err;
    struct addrinfo *result;
    struct addrinfo hints = {
    .ai_family = AF_INET,
    #ifdef USE_UDP
    .ai_socktype = SOCK_DGRAM

    #else
    .ai_socktype = SOCK_STREAM
    #endif

    -------

    static int client_init(void)
    {
    int err;

    #ifdef USE_UDP
    sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
    #else
    sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
    #endif

Children
No Data
Related