From: Pascal B. <pj...@in...> - 2005-08-31 22:23:05
|
Sam Steingold writes: > > * Pascal Bourguignon <cwo@vasbezngvzntb.pbz> [2005-08-31 19:13:30 +0200]: > > > > While the CLHS description of LISTEN use the term character, it > > doesn't specify a character input stream, just a mere input stream. > > Since most internet protocols have a binary specification (despite the > > fact that ASCII encoding is often used for meta data), I'd suggest too > > implement LISTEN to work on binary streams too. > > this would require just a trivial change. > the only question is: > will the change be really ANSI-compliant. > please investigate what the other implementation do (after all, the > standard expresses the vendor consensus), and raise the issue on the > c.l.l. clisp no 2.35 either either cmucl yes 18e Linux ix86 gcl no 2.6.7 Linux ix86 ; it seems we can't specify the element type. ecl yes 0.9g Linux ix86 openmcl yes 0.14.3 MacOSX ppc sbcl yes 0.9.0 Linux ix86 There seems to be a concensus toward LISTEN working on binary streams. ------------------------------------------------------------------------ clisp: listen doesn't work on binary socket streams: (let ((s (socket:socket-connect 110 "larissa" :element-type '(unsigned-byte 8)))) (unwind-protect (loop while (/= 10 (princ (read-byte s))) do (princ " ") (princ (listen s)) (princ " ")) (close s))) 43 NIL 79 NIL 75 NIL 32 NIL 114 NIL 101 NIL 97 NIL 100 NIL 121 NIL 32 NIL 32 NIL 60 NIL 49 NIL 53 NIL 48 NIL 57 NIL 57 NIL 46 NIL 49 NIL 49 NIL 50 NIL 53 NIL 53 NIL 49 NIL 56 NIL 48 NIL 56 NIL 52 NIL 64 NIL 108 NIL 97 NIL 114 NIL 105 NIL 115 NIL 115 NIL 97 NIL 46 NIL 105 NIL 110 NIL 102 NIL 111 NIL 114 NIL 109 NIL 97 NIL 116 NIL 105 NIL 109 NIL 97 NIL 103 NIL 111 NIL 46 NIL 99 NIL 111 NIL 109 NIL 62 NIL 13 NIL 10 NIL ------------------------------------------------------------------------ cmucl: listen works on binary socket streams: * (let* ((sock (ext:connect-to-inet-socket "larissa" 110)) (s (system:make-fd-stream sock :input t :output t :element-type '(unsigned-byte 8) :buffering :none))) (unwind-protect (loop while (/= 10 (princ (read-byte s))) do (princ " ") (princ (listen s)) (princ " ")) (close s))) 43 T 79 T 75 T 32 T 114 T 101 T 97 T 100 T 121 T 32 T 32 T 60 T 49 T 53 T 49 T 51 T 51 T 46 T 49 T 49 T 50 T 53 T 53 T 49 T 56 T 51 T 48 T 50 T 64 T 108 T 97 T 114 T 105 T 115 T 115 T 97 T 46 T 105 T 110 T 102 T 111 T 114 T 109 T 97 T 116 T 105 T 109 T 97 T 103 T 111 T 46 T 99 T 111 T 109 T 62 T 13 T 10 NIL * ------------------------------------------------------------------------ gcl: listen doesn't work on binary socket streams: >(let ((s (system:SOCKET 110 :host "larissa" :async nil))) (unwind-protect (loop while (/= 10 (princ (read-byte s))) do (princ " ") (princ (listen s)) (princ " ")) (close s))) 43 NIL 79 NIL 75 NIL 32 NIL 114 NIL 101 NIL 97 NIL 100 NIL 121 NIL 32 NIL 32 NIL 60 NIL 49 NIL 55 NIL 54 NIL 48 NIL 50 NIL 46 NIL 49 NIL 49 NIL 50 NIL 53 NIL 53 NIL 50 NIL 54 NIL 54 NIL 56 NIL 51 NIL 64 NIL 108 NIL 97 NIL 114 NIL 105 NIL 115 NIL 115 NIL 97 NIL 46 NIL 105 NIL 110 NIL 102 NIL 111 NIL 114 NIL 109 NIL 97 NIL 116 NIL 105 NIL 109 NIL 97 NIL 103 NIL 111 NIL 46 NIL 99 NIL 111 NIL 109 NIL 62 NIL 13 NIL 10 NIL ------------------------------------------------------------------------ ecl: listen works on binary socket streams: > (list-all-packages) (#<"SB-BSD-SOCKETS" package> #<"WALKER" package> #<"FFI" package> #<"CLOS" package> #<"SI" package> #<"KEYWORD" package> #<"COMMON-LISP-USER" package> #<"COMMON-LISP" package>) > (let ((sock (make-instance 'sb-bsd-sockets:inet-socket :type :stream :protocol :tcp))) (sb-bsd-sockets:socket-bind sock #(0 0 0 0) 0) (sb-bsd-sockets:socket-connect sock #(62 93 174 78) 110) (let ((s (sb-bsd-sockets:socket-make-stream sock :element-type '(unsigned-byte 8)))) (unwind-protect (loop while (/= 10 (princ (read-byte s))) do (princ " ") (princ (listen s)) (princ " ")) (close s)))) 43 T 79 T 75 T 32 T 114 T 101 T 97 T 100 T 121 T 32 T 32 T 60 T 49 T 55 T 53 T 49 T 49 T 46 T 49 T 49 T 50 T 53 T 53 T 50 T 54 T 51 T 55 T 51 T 64 T 108 T 97 T 114 T 105 T 115 T 115 T 97 T 46 T 105 T 110 T 102 T 111 T 114 T 109 T 97 T 116 T 105 T 109 T 97 T 103 T 111 T 46 T 99 T 111 T 109 T 62 T 13 T 10 NIL > (lisp-implementation-type) "ECL" > ------------------------------------------------------------------------ openmcl: listen works on binary socket streams: > (openmcl-socket:with-open-socket (s :format :binary :remote-host "larissa" :remote-port 110) (openmcl-socket:socket-connect s) (loop while (/= 10 (princ (read-byte s))) do (princ " ") (princ (listen s)) (princ " "))) 43 T 79 T 75 T 32 T 114 T 101 T 97 T 100 T 121 T 32 T 32 T 60 T 49 T 53 T 52 T 48 T 57 T 46 T 49 T 49 T 50 T 53 T 53 T 49 T 57 T 55 T 50 T 49 T 64 T 108 T 97 T 114 T 105 T 115 T 115 T 97 T 46 T 105 T 110 T 102 T 111 T 114 T 109 T 97 T 116 T 105 T 109 T 97 T 103 T 111 T 46 T 99 T 111 T 109 T 62 T 13 T 10 NIL > ------------------------------------------------------------------------ sbcl: listen works on binary socket streams: (let ((sock (make-instance 'sb-bsd-sockets:inet-socket :type :stream :protocol :tcp))) (sb-bsd-sockets:socket-bind sock #(0 0 0 0) 0) (sb-bsd-sockets:socket-connect sock #(62 93 174 78) 110) (let ((s (sb-bsd-sockets:socket-make-stream sock :element-type '(unsigned-byte 8)))) (unwind-protect (loop while (/= 10 (princ (read-byte s))) do (princ " ") (princ (listen s)) (princ " ")) (close s)))) 43 T 79 T 75 T 32 T 114 T 101 T 97 T 100 T 121 T 32 T 32 T 60 T 49 T 53 T 48 T 56 T 54 T 46 T 49 T 49 T 50 T 53 T 53 T 49 T 56 T 48 T 48 T 53 T 64 T 108 T 97 T 114 T 105 T 115 T 115 T 97 T 46 T 105 T 110 T 102 T 111 T 114 T 109 T 97 T 116 T 105 T 109 T 97 T 103 T 111 T 46 T 99 T 111 T 109 T 62 T 13 T 10 NIL ------------------------------------------------------------------------ -- "A TRUE Klingon warrior does not comment his code!" |