| 166 | \*-------------------------------------------------------------------------*/ |
| 167 | #define STEPSIZE 8192 |
| 168 | static int sendraw(p_buffer buf, const char *data, size_t count, size_t *sent) { |
| 169 | p_io io = buf->io; |
| 170 | p_timeout tm = buf->tm; |
| 171 | size_t total = 0; |
| 172 | int err = IO_DONE; |
| 173 | while (total < count && err == IO_DONE) { |
| 174 | size_t done = 0; |
| 175 | size_t step = (count-total <= STEPSIZE)? count-total: STEPSIZE; |
| 176 | err = io->send(io->ctx, data+total, step, &done, tm); |
| 177 | total += done; |
| 178 | } |
| 179 | *sent = total; |
| 180 | buf->sent += total; |
| 181 | return err; |
| 182 | } |
| 183 | |
| 184 | /*-------------------------------------------------------------------------*\ |
| 185 | * Reads a fixed number of bytes (buffered) |