David L. Rager | 8 Sep 23:31

Re: [OpenMCL/CCL Devel] Send and receive data via CCL sockets

Nice, that works quite well, thanks.

Now, I'm trying to figure out how to actually send and receive data.
If I use format to write a string to the stream, how do I make the
other process read the string?  A read (triggered with a call to
"(read der)" of the stream on the server just hangs (a backtrace shows
it's waiting in FD-READ, which was called by FD-Stream-Advance).

Note: "der" is set to the stream generated from the socket labeled
"der" in the example sent out by Karsten.

On Mon, Sep 8, 2008 at 4:31 PM, David Rager <ragerdl <at> gmail.com> wrote:
> Nice, that works quite well, thanks.
>
> Now, I'm trying to figure out how to actually send and receive data.
> If I use format to write a string to the stream, how do I make the
> other process read the string?  A read (triggered with a call to
> "(read der)" of the stream on the server just hangs (a backtrace shows
> it's waiting in FD-READ, which was called by FD-Stream-Advance).
>
> Note: "der" is set to the stream generated from the socket labeled
> "der" in the example sent out by Karsten.
>
> On Mon, Sep 8, 2008 at 2:42 PM, Karsten Poeck <karsten.poeck <at> gmail.com> wrote:
>> Hello,
>> I use the following:
>> (defun %make-client-socket (host &key port)
>>  (ccl:make-socket :remote-host host
>>                   :remote-port port
>>                   :type :stream
(Continue reading)

Gary Byers | 9 Sep 02:22

Re: [OpenMCL/CCL Devel] Send and receive data via CCL sockets

If only CL provided some function to FORCE-OUTPUT on a buffered stream.
That hypothetical FORCE-OUTPUT function sure would come in handy in
cases like this ...

One might legitimately ask why the lisp doesn't call FORCE-OUTPUT
for you, as it does on *TERMINAL-IO* and its synonym streams.  I 
could imagine that making output line-buffered (e.g., to have
FORCE-OUTPUT called every time a newline is written) could sometimes
be useful, as could forcing output before reading input.  Whether
those behaviors would in fact be useful depends  lot on the higher
level protocol.  You can probably generalize some of this, but
I think that it's hard to do a very good job of that.

(For instance, when writing an SMTP server, it would be desirable to
call FORCE-OUTPUT after sending the last line of a multiline response,
but it might be less efficient to call FORCE-OUTPUT after each line.
You might wind up writing a server that reads command lines and
writes response lines as something like:

(loop
   (force-output socket)  ; ensure that buffered output is sent
   (let* ((command-lines ()))
     ;; read one or more command lines
     (do* ((line (read-line socket nil nil) (read-line socket nil nil)))
          ((null line)) ; EOF ?
       (push line command-lines)
       (if (not (is-continuation-line line))
         (return)))
     (process-command-lines (nreverse command-lines))))

(Continue reading)


Gmane