1 %%% Copyright (c) 2007- Facebook
2 %%% Distributed under the Thrift Software License
4 %%% See accompanying file LICENSE or visit the Thrift site at:
5 %%% http://developers.facebook.com/thrift/
11 -include("thrift.hrl").
12 -include("transport/tTransport.hrl").
16 -export([attr
/4, super
/0, inspect
/1]).
18 -export([new
/0, isOpen
/1, effectful_open
/1, effectful_close
/1, read
/2, readAll
/2, effectful_write
/2, effectful_flush
/1]).
22 %%% 'super' is required unless ?MODULE is a base class
28 %%% behavior callbacks
31 %%% super() -> SuperModule = atom()
37 %%% inspect(This) -> string()
54 exit('tTransport is abstract').
60 effectful_open(This
) ->
64 effectful_close(This
) ->
73 readAll_loop(This
, Sz
, "", 0).
75 readAll_loop(This
, Sz
, Buff
, Have
) ->
78 Chunk
= ?
L1(read
, Sz
- Have
),
81 %% exactly Length bytes are returned, or an error;
82 %% possibly discarding less than Length bytes of data when
83 %% the socket gets closed from the other side.
85 %% error_logger:info_msg("READ |~p|", [Chunk]),
87 Have1
= Have
+ (Sz
-Have
), % length(Chunk)
88 Buff1
= Buff
++ Chunk
, % TODO: ++ efficiency?
89 readAll_loop(This
, Sz
, Buff1
, Have1
);
94 effectful_write(This
, _Buf
) ->
98 effectful_flush(This
) ->