Rev 30 | Blame | Compare with Previous | Last modification | View Log | RSS feed
---- Licensed to the Apache Software Foundation (ASF) under one-- or more contributor license agreements. See the NOTICE file-- distributed with this work for additional information-- regarding copyright ownership. The ASF licenses this file-- to you under the Apache License, Version 2.0 (the-- "License"); you may not use this file except in compliance-- with the License. You may obtain a copy of the License at---- http://www.apache.org/licenses/LICENSE-2.0---- Unless required by applicable law or agreed to in writing,-- software distributed under the License is distributed on an-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY-- KIND, either express or implied. See the License for the-- specific language governing permissions and limitations-- under the License.--module Thrift.Transport.Handle( module Thrift.Transport, HandleSource(..)) whereimport Control.Exception ( throw )import Control.Monad ( replicateM )import Networkimport System.IOimport System.IO.Error ( isEOFError )import Thrift.Transportinstance Transport Handle wheretIsOpen = hIsOpentClose h = hClose htRead h n = replicateM n (hGetChar h) `catch` handleEOFtWrite h s = mapM_ (hPutChar h) stFlush = hFlush-- | Type class for all types that can open a Handle. This class is used to-- replace tOpen in the Transport type class.class HandleSource s wherehOpen :: s -> IO Handleinstance HandleSource FilePath wherehOpen s = openFile s ReadWriteModeinstance HandleSource (HostName, PortID) wherehOpen = uncurry connectTohandleEOF e = if isEOFError ethen return []else throw $ TransportExn "TChannelTransport: Could not read" TE_UNKNOWN