Wip_cev_write


#1

Im running the Sample TCP client application for the q2627. This application establishes a connection and sends data stored in a buffer. The wip_write functionion is called to do this. However, this function is called only when WIP_CEV_WRITE is given to the event handler.

My question is, what triggers this event? I was thinking it is triggered if data is present in the buffer, but I dont see how this buffer is linked to any events.

case WIP_CEV_WRITE: {
    int nwrite;
    wip_debug ("[SAMPLE] Can send more data\n");
   [b] nwrite = wip_write( ev->channel, snd_buffer + snd_offset,[/b]
                        sizeof( snd_buffer) - snd_offset);
    if( nwrite < 0) { wip_debug( "[SAMPLE] write error %i\n", nwrite); return; }
    snd_offset += nwrite;
    if( snd_offset == sizeof( snd_buffer)) {
      wip_debug( "[SAMPLE] Everything has been sent, won't send more.\n");
    } else {
      wip_debug( "[SAMPLE] Wrote %i bytes. "
                 "%i bytes left to send in snd_buffer\n",
                 nwrite, sizeof( snd_buffer) - snd_offset);
    }
    break;

Does anyone know how to trigger this event??


#2

If you open the client and it is fully initialized the WIP_CEV_WRITE event gets triggered because the client is ready to send data.

you actually send the data using wip_write().
this function can only send an finite amount of data, so it returns how much data has actually been sent.
you must wait calling wip_write() to send new (or remaining data) to your server until the WIP_CEV_WRITE event has been fired again.