- if (err == ERR_OK) {
- outputf("RFB: attempting send %d", sndlength);
- } else {
- outputf("RFB: send error %d", err);
+ outputf("actually sent");
+ state->chunk_actually_sent = 1;
+
+ /* Send a header */
+ hdr.msgtype = 0;
+ state->chunk_lindex = 0;
+ hdr.nrects = htons(1);
+ hdr.xpos = htons(state->chunk_xpos);
+ hdr.ypos = htons(state->chunk_ypos);
+ hdr.width = htons(state->chunk_width);
+ hdr.height= htons(state->chunk_height);
+ hdr.enctype = htonl(0);
+ lines_left = state->chunk_height;
+
+ err = tcp_write(pcb, &hdr, sizeof(hdr), TCP_WRITE_FLAG_COPY);
+
+ if (err != ERR_OK) {
+ if (err != ERR_MEM)
+ outputf("RFB: header send error %d", err);
+
+ /* Try again later. */
+ return;
+ }
+
+ state->send_state = SST_DATA;
+
+ /* FALL THROUGH to SST_DATA */
+
+ case SST_DATA:
+
+ lines_left = state->chunk_height - state->chunk_lindex;
+
+ if (lines_left == 0) {
+ state->send_state = SST_HEADER;
+ state->checksums[state->chunk_xnum][state->chunk_ynum] = state->chunk_checksum;
+ if (advance_chunk(state))
+ return;