JuliaLang / MbedTLS.jl

Wrapper around mbedtls
Other
41 stars 50 forks source link

ERROR: MbedTLS.SSLContext does not support byte I/O #197

Open biluohc opened 5 years ago

biluohc commented 5 years ago

Can you support this? The ordinary socket could be read by readuntil and 'readline' funtions.

julia> readline(c)
ERROR: MbedTLS.SSLContext does not support byte I/O
Stacktrace:
 [1] error(::Type, ::String) at ./error.jl:42
 [2] read(::MbedTLS.SSLContext, ::Type{UInt8}) at ./io.jl:182
 [3] #readuntil#290 at ./io.jl:653 [inlined]
 [4] #readuntil at ./none:0 [inlined]
 [5] #readline#284(::Bool, ::Function, ::MbedTLS.SSLContext) at ./io.jl:370
 [6] readline(::MbedTLS.SSLContext) at ./io.jl:370
 [7] top-level scope at none:0
samoconnor commented 5 years ago

My feeling is that supporting one-byte-at-a-time IO, and thereby allowing use of readuntil, readline, etc would encourage inefficient code because one-byte-at-a-time loop inside readuntil would call all the way down into the TLS library. Better to use a buffering wrapper like https://github.com/BioJulia/BufferedStreams.jl

biluohc commented 5 years ago

@samoconnor ,Thanks you, I used IOBuffer finally.