Thanks!

--- On Thu, 29/4/10, Sam Steingold <sds@gnu.org> wrote:

From: Sam Steingold <sds@gnu.org>
Subject: Re: ext:write-char-sequence :no-hang t
To: "Angel Popov" <angelpopov@yahoo.com>
Cc: "cdev" <clisp-devel@lists.sourceforge.net>
Date: Thursday, 29 April, 2010, 5:22 PM

Hi,

Angel Popov wrote:
> I tried to use ext:write-char-sequence with :no-hang t but it gives me and error.
>
>
> [7]> (setf socket (socket:socket-connect 80 "www.google.com" :element-type '(unsigned-byte 8)))
> #<IO INPUT-BUFFERED SOCKET-STREAM (UNSIGNED-BYTE 8) www.google.com:80>
> [8]> (ext:write-byte-sequence (mapcar #'char-code (coerce (format nil "GET / HTTP/1.1~2%") 'list)) socket)
> (71 69 84 32 47 32 72 84 84 80 47 49 46 49 10 10) ;
> 16

this is not particularly efficient (a write(2) for every character).
you should do either
(ext:write-char-sequence (format nil "GET / HTTP/1.1~2%") socket)
or
(ext:write-byte-sequence
(ext:convert-string-to-bytes
  (format nil "GET / HTTP/1.1~2%") encoding:ascii)
socket)
which calls write(2) just once.

> [9]> (ext:write-byte-sequence (mapcar #'char-code (coerce (format nil "GET / HTTP/1.1~2%") 'list)) socket :no-hang t)
>
> *** - WRITE-BYTE-SEQUENCE on #<IO INPUT-BUFFERED SOCKET-STREAM (UNSIGNED-BYTE 8) www.google.com:80> is illegal

the message is, indeed, confusing.
the reason for the message is, however, simple: write_byte_will_hang_p is not implemented yet, so ":no-hang t" does not work.

http://www.cygwin.com/acronyms/#PTC