| method isOpen = chans != None |
| chans <- Some(Unix.open_connection (Unix.ADDR_INET ((Unix.inet_addr_of_string host),port))) |
| ("Could not connect to "^host^":"^(string_of_int port)) |
| method close = match chans with None -> () | Some(inc,_) -> (Unix.shutdown_connection inc; chans <- None) |
| method read buf off len = match chans with |
| None -> T.raise_TTransportExn "Socket not open" T.NOT_OPEN |
| really_input i buf off len; len |
| with _ -> T.raise_TTransportExn ("TSocket: Could not read "^(string_of_int len)^" from "^host^":"^(string_of_int port)) T.UNKNOWN |
| method write buf off len = match chans with |
| None -> T.raise_TTransportExn "Socket not open" T.NOT_OPEN |
| | Some(i,o) -> output o buf off len |
| method flush = match chans with |
| None -> T.raise_TTransportExn "Socket not open" T.NOT_OPEN |