[plt-scheme] Re: ssl/tls connections

From: Paraita (milkyboi at gmail.com)
Date: Mon Mar 30 02:21:35 EDT 2009

Hi,
i'm a french IT student, so i don't know if my code will help you
anyway.
I didn't go far enough to implement secure negotiation but i managed
to read from port directly with read-string.

; recupServer: port -> string
; return the "first" block not null
(define (recupServer->me port)
    (let loop ()
      (let ([available (peek-string TAILLEBLOCK 0 port)])
        (if (null? available)
            (loop)
            (read-string TAILLEBLOCK port)))))



On 29 mar, 17:08, nik gaffney <n... at fo.am> wrote:
> Im working on a basic implementation of the xmpp/jabber protocol, and
> having some trouble dealing with tls and sasl negotiation. I have a
> working plaintext version, using tcp-connect, but changing to
> ssl-connect has revealed some underlying problems.
>
> The current approach involves using ssax to convert a string read from
> the tcp stream. for some reason, read-line and read-char both hang when
> reading from ejabberd, so im using read-byte.
>
> Since byte-ready? is #f after a stanza has been sent, the following
> function can be used to successfully parse individual responses from the
> server.
>
> (parse-xmpp-response (bytes->string/utf-8 (read-async in)))
>
> (define (read-async in)
>   (define bstr (make-bytes 0 0))
>   (when (byte-ready? in)
>     (if (eq? (peek-byte in) eof)
>         (break-thread (current-thread))
>         (begin
>           (set! bstr (bytes-append bstr
>                                    (make-bytes 1 (read-byte in))
>                                    (read-async in)))))) bstr)
>
> Unfortunately, this causes problems with ssl-connect (as described in
> the openssl docs) as the ssl session is committed to a read by
> byte-ready? thus writes are blocked until the server sends data.
>
> So, I was wondering what other approaches to reading from a port would
> get around this problem, and/or if there are any examples anyone could
> point me to.
>
> thanks,
> nik
>
> _________________________________________________
>   For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme


Posted on the users mailing list.