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, open
/1, 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').
56 isOpen(_This
) -> e(), nil
.
57 open(_This
) -> e(), nil
.
58 close(_This
) -> e(), nil
.
59 read(_This
, _Sz
) -> e(), nil
.
62 readAll_loop(This
, Sz
, "", 0).
64 readAll_loop(This
, Sz
, Buff
, Have
) ->
67 Chunk
= ?
L1(read
, Sz
- Have
),
70 %% exactly Length bytes are returned, or an error;
71 %% possibly discarding less than Length bytes of data when
72 %% the socket gets closed from the other side.
74 %% error_logger:info_msg("READ |~p|", [Chunk]),
76 Have1
= Have
+ (Sz
-Have
), % length(Chunk)
77 Buff1
= Buff
++ Chunk
, % TODO: ++ efficiency?
78 readAll_loop(This
, Sz
, Buff1
, Have1
);
83 effectful_write(This
, _Buf
) ->
87 effectful_flush(This
) ->