4 ms·
Is it easy to create non-blocking TLS socket connections with Julia? How about making an HTTPS request? If Julia has async operations, are they inline, promises
by leobelle 13y ago
Is it easy to create non-blocking TLS socket connections with Julia? How about making an HTTPS request? If Julia has async operations, are they inline, promises, events or callbacks?
- KenoFischer 13y agoYes, actually, this is quite easy. Basically the I/O model uses cooperative coroutines. For TLS, you'll want to look at https://github.com/loladiro/GnuTLS.jl https://github.com/loladiro/GnuTLS.jl. Then, after setting up the stream with the underlying socket, protocol information, etc. (see the README for how to specify this), you can just use it as any other IO stream... # Set up stream `sock` here @async begin println(sock,"Hello World") line = readline(sock) println(sock,"You typed ",line) end Basically the encryption happens on the fly and the stream can be used just like any other socket. For example, in the http client code here: https://github.com/loladiro/Requests.jl/blob/master/src/Requests.jl#L197-L204 https://github.com/loladiro/Requests.jl/blob/master/src/Requ..., the only difference between HTTP and HTTPS is how the socket is set up, the actual reading and writing is the same. Hope that helps!