+ /* Snag the data. */
+ fb->copy_pixels(state->blockbuf,
+ state->chunk_xpos, state->chunk_ypos,
+ state->chunk_width, state->chunk_height);
+
+ /* FALL THROUGH to SST_DATA */
+
+ case SST_DATA:
+
+ bytes_left = 4 * state->chunk_width * state->chunk_height - state->chunk_bytes_sent;
+
+ if (bytes_left == 0) {
+ state->send_state = SST_HEADER;
+ state->checksums[state->chunk_xnum][state->chunk_ynum] = state->chunk_checksum;
+ if (advance_chunk(state))
+ return;
+ break;
+ }
+
+ /* That's enough. */
+ if (bytes_left > 1400) {
+ bytes_left = 1400;
+ }
+
+ err = tcp_write(pcb, state->blockbuf + state->chunk_bytes_sent,
+ bytes_left, TCP_WRITE_FLAG_COPY);
+
+ if (err == ERR_OK) {
+ state->chunk_bytes_sent += bytes_left;
+ } else {
+ if (err != ERR_MEM)
+ outputf("RFB: send error %d", err);
+
+ return;
+ }
+
+ if (tcp_sndbuf(pcb) == 0) {
+ return;
+ }
+ }