diff options
Diffstat (limited to 'common/trans.c')
-rw-r--r-- | common/trans.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/common/trans.c b/common/trans.c index 9611f768..525316c5 100644 --- a/common/trans.c +++ b/common/trans.c @@ -490,6 +490,7 @@ trans_force_read(struct trans *self, int size) return trans_force_read_s(self, self->in_s, size); } +#if 0 /*****************************************************************************/ int APP_CC trans_force_write_s(struct trans *self, struct stream *out_s) @@ -550,6 +551,55 @@ trans_force_write_s(struct trans *self, struct stream *out_s) } return 0; } +#else +// DEBUG ONLY +/*****************************************************************************/ +int APP_CC +trans_force_write_s(struct trans* self, struct stream* out_s) +{ + int size; + int total; + int sent; + + if (self->status != TRANS_STATUS_UP) + { + return 1; + } + size = (int)(out_s->end - out_s->data); + total = 0; + while (total < size) + { + sent = g_tcp_send(self->sck, out_s->data + total, size - total, 0); + if (sent == -1) + { + if (g_tcp_last_error_would_block(self->sck)) + { + if (!g_tcp_can_send(self->sck, 10)) + { + /* check for term here */ + } + } + else + { + /* error */ + self->status = TRANS_STATUS_DOWN; + return 2; + } + } + else if (sent == 0) + { + /* error */ + self->status = TRANS_STATUS_DOWN; + return 3; + } + else + { + total = total + sent; + } + } + return 0; +} +#endif /*****************************************************************************/ int APP_CC |