iproctor | 9a41a0c | 2007-07-16 21:59:24 +0000 | [diff] [blame] | 1 | open Thrift |
| 2 | module T = Transport |
| 3 | |
| 4 | class t (i,o) = |
| 5 | object (self) |
iproctor | e470aa3 | 2007-08-10 20:48:12 +0000 | [diff] [blame^] | 6 | val mutable opened = true |
iproctor | 9a41a0c | 2007-07-16 21:59:24 +0000 | [diff] [blame] | 7 | inherit Transport.t |
iproctor | e470aa3 | 2007-08-10 20:48:12 +0000 | [diff] [blame^] | 8 | method isOpen = opened |
iproctor | 9a41a0c | 2007-07-16 21:59:24 +0000 | [diff] [blame] | 9 | method opn = () |
iproctor | e470aa3 | 2007-08-10 20:48:12 +0000 | [diff] [blame^] | 10 | method close = close_in i; opened <- false |
iproctor | 9a41a0c | 2007-07-16 21:59:24 +0000 | [diff] [blame] | 11 | method read buf off len = |
iproctor | e470aa3 | 2007-08-10 20:48:12 +0000 | [diff] [blame^] | 12 | if opened then |
| 13 | try |
| 14 | really_input i buf off len; len |
| 15 | with _ -> raise (T.E (T.UNKNOWN, ("TChannelTransport: Could not read "^(string_of_int len)))) |
| 16 | else |
| 17 | raise (T.E (T.NOT_OPEN, "TChannelTransport: Channel was closed")) |
iproctor | 9a41a0c | 2007-07-16 21:59:24 +0000 | [diff] [blame] | 18 | method write buf off len = output o buf off len |
| 19 | method flush = flush o |
| 20 | end |