Example #1
0
static int processSrqIo(user_data_t * user_data) {
    int rc;
    char smbuffer[10];  
    rc = recv(user_data->control_io, smbuffer, sizeof(smbuffer), 0);
    if (rc < 0) {
        if (errno != EWOULDBLOCK) {
            closeSrqIo(user_data);
            perror("  recv() failed");
        }
    } else if (rc == 0) {
        closeSrqIo(user_data);
        printf("Control Connection closed\r\n");
    } else {
        // nothing to do
    }
}
Example #2
0
static int processSrqIo(user_data_t * user_data) {
    struct netbuf *inbuf;
    char* buf;
    u16_t buflen;    

    if (netconn_recv(user_data->control_io, &inbuf) != ERR_OK) {
        goto fail1;
    }
    if (netconn_err(user_data->control_io) != ERR_OK) {
        goto fail2;
    }
    
    netbuf_data(inbuf, (void**) &buf, &buflen);

    if (buflen > 0) {
        // TODO process control
    } else {
        //goto fail2;
    }
    
    netbuf_delete(inbuf);

    return 0;
    
fail2:
    netbuf_delete(inbuf);
fail1:
    closeSrqIo(user_data);
    
    return 0;
}