[plt-scheme] ssl/tls connections

From: nik gaffney (nik at fo.am)
Date: Tue Mar 31 10:34:15 EDT 2009

>> 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.
> 
> Try syncing on the input and output ports, rather than peeking.

could you explain how this would work? Ive tried using sync in the read
thread, without any change, but am not clear how to sync between the
read & write threads.

> don't know for sure but I guess that sync is implemented in terms of
> select, and the OpenSSL docs suggest you can use select to determine
> if data is ready without committing to a read or a write.

I had a quick look at sema.c and port.c files, which looked relevant,
but sill somewhat opaque to me.. .

http://svn.plt-scheme.org/view/trunk/src/mzscheme/src/

> I expect your funciton read-async below could be better written. Two things:

thanks for the suggestions and the pointer to sync. ive cleaned it up a
bit, but i guess it still depends on how sync is implemented. ..

(define (read-async in)
    (let ((bstr '()))
      (when (sync/timeout 0 in)
        (set! bstr (cons (read-byte in) (read-async in)))) bstr))

thanks,
nk


Posted on the users mailing list.