aboutsummaryrefslogtreecommitdiff
path: root/jim_tcl.txt
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2020-05-02 16:37:46 +1000
committerSteve Bennett <steveb@workware.net.au>2020-05-06 11:22:52 +1000
commit90669224d718ec875d83df47694370d1cc6ccf23 (patch)
tree6552ff10b29e41ea9ef2f566e6d558ca6508d6a6 /jim_tcl.txt
parentf8be02f204b55daaee5304e8ee99294612b29737 (diff)
downloadjimtcl-90669224d718ec875d83df47694370d1cc6ccf23.zip
jimtcl-90669224d718ec875d83df47694370d1cc6ccf23.tar.gz
jimtcl-90669224d718ec875d83df47694370d1cc6ccf23.tar.bz2
aio: Fix eventloop and eof for ssl connections
We can't use feof() and 'buffering none' on ssl connections. Instead we have to get eof from the ssl layer, and provide special handling for buffering in the eventloop. For eof, add ssl_eof() and detect SSL_read() results that indicate eof to set AIO_EOF in flags. For buffering, add 'read -pending' that will read, and then immediately read any buffered data so that the 'readable' event will trigger next time. Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim_tcl.txt')
-rw-r--r--jim_tcl.txt23
1 files changed, 21 insertions, 2 deletions
diff --git a/jim_tcl.txt b/jim_tcl.txt
index 0ba2e5b..d0f3b25 100644
--- a/jim_tcl.txt
+++ b/jim_tcl.txt
@@ -3574,6 +3574,10 @@ read
+'fileId' *read* 'numBytes'+
++*read* ?*-pending*? 'fileId'+
+
++'fileId' *read* ?*-pending*?+
+
In the first form, all of the remaining bytes are read from the file
given by +'fileId'+; they are returned as the result of the command.
If the +-nonewline+ switch is specified then the last
@@ -3584,6 +3588,21 @@ exactly this many bytes will be read and returned, unless there are fewer than
+'numBytes'+ bytes left in the file; in this case, all the remaining
bytes are returned.
+The third form is currently only useful with SSL sockets. It reads at least 1 byte
+and then any additional data that is buffered. This allows for use in an event handler.
+e.g.
+
+----
+ $sock readable {
+ set buf [$sock read -pending]
+ }
+----
+
+This is necessary because otherwise pending data may be buffered, but
+the underlying socket will not be marked 'readable'. This featured is not
+currently supported for regular sockets, and so these sockets must be
+set to unbufferred (+$sock buffering false+) to work in an event loop.
+
+'fileId'+ must be +stdin+ or the return value from a previous call
to `open`; it must refer to a file that was opened for reading.
@@ -4753,8 +4772,8 @@ aio
+$handle *puts ?-nonewline?* 'str'+::
Write the string, with newline unless -nonewline
-+$handle *read ?-nonewline?* '?len?'+::
- Read and return bytes from the stream. To eof if no len.
++$handle *read ?-nonewline|-pending*|len?'+::
+ Read and return bytes from the stream. To eof if no len. See `read`.
+$handle *recvfrom* 'maxlen ?addrvar?'+::
Receives a message from the handle via recvfrom(2) and returns it.