blob: 9678e5ab8508081882395e1b63f3e3b324f5cf14 [file] [log] [blame]
iproctor9a41a0c2007-07-16 21:59:24 +00001open Thrift
2module T = Transport
3
4class t (i,o) =
5object (self)
iproctore470aa32007-08-10 20:48:12 +00006 val mutable opened = true
iproctor9a41a0c2007-07-16 21:59:24 +00007 inherit Transport.t
iproctore470aa32007-08-10 20:48:12 +00008 method isOpen = opened
iproctor9a41a0c2007-07-16 21:59:24 +00009 method opn = ()
iproctore470aa32007-08-10 20:48:12 +000010 method close = close_in i; opened <- false
David Reiss0c90f6f2008-02-06 22:18:40 +000011 method read buf off len =
iproctore470aa32007-08-10 20:48:12 +000012 if opened then
David Reiss0c90f6f2008-02-06 22:18:40 +000013 try
iproctore470aa32007-08-10 20:48:12 +000014 really_input i buf off len; len
15 with _ -> raise (T.E (T.UNKNOWN, ("TChannelTransport: Could not read "^(string_of_int len))))
David Reiss0c90f6f2008-02-06 22:18:40 +000016 else
iproctore470aa32007-08-10 20:48:12 +000017 raise (T.E (T.NOT_OPEN, "TChannelTransport: Channel was closed"))
iproctor9a41a0c2007-07-16 21:59:24 +000018 method write buf off len = output o buf off len
19 method flush = flush o
20end