X-Git-Url: http://git.kpe.io/?p=cl-modlisp.git;a=blobdiff_plain;f=compat.lisp;h=e76b7ff49cdb1d5ff5116a592d46e95d18326928;hp=1b6c62fe7fbdc90fe0e3a0b06865dc453c1939a4;hb=be22beac4a99bf6f426c34fbd29b5820e7c57e40;hpb=cb60460c044d8e4c1270b30acd43853ef4ef8f94 diff --git a/compat.lisp b/compat.lisp index 1b6c62f..e76b7ff 100644 --- a/compat.lisp +++ b/compat.lisp @@ -1,5 +1,5 @@ ;;; -*- Syntax: Ansi-Common-Lisp; Base: 10; Mode: lisp; Package: clit -*- -;;; $Id: compat.lisp,v 1.1 2003/07/08 06:43:29 kevin Exp $ +;;; $Id: compat.lisp,v 1.3 2003/07/08 12:10:16 kevin Exp $ (in-package #:modlisp) @@ -43,7 +43,33 @@ #+lispworks (progn - (defclass socket () + +(define-condition lw-stream-error (error) + ((stream :initarg :stream + :reader stream-error-stream) + (action :initarg :action + :reader stream-error-action) + (code :initarg :code + :reader stream-error-code) + (identifier :initarg :identifier + :reader stream-error-identifier)) + (:report (lambda (condition stream) + (format stream "A stream error occured (action=~A identifier=~A code=~A stream=~S)." + (stream-error-action condition) + (stream-error-identifier condition) + (stream-error-code condition) + (stream-error-stream condition))))) + +(define-condition socket-error (lw-stream-error) + () + (:report (lambda (condition stream) + (format stream "A socket error occured (action=~A identifier=~A code=~A stream=~S)." + (stream-error-action condition) + (stream-error-identifier condition) + (stream-error-code condition) + (stream-error-stream condition))))) + +(defclass socket () ((passive-socket :type fixnum :initarg :passive-socket :reader socket-os-fd))) @@ -168,7 +194,8 @@ setsockopt SO_REUSEADDR if :reuse is not nil" (make-instance 'passive-socket :port port :passive-socket (%new-passive-socket port) - :element-type format)) + :element-type (case format + (:text 'base-char)))) ) (defun make-fd-stream (socket &key input output element-type) @@ -202,10 +229,12 @@ setsockopt SO_REUSEADDR if :reuse is not nil" #+clisp (ext:socket-accept listener) #+lispworks - (when (stream-input-available listener) + (progn + (loop while (not (stream-input-available listener)) + do (sleep 1)) (make-instance 'bidirectional-binary-socket-stream :socket (comm::get-fd-from-socket - (socket-os-fd passive-socket)) + (socket-os-fd listener)) :direction :io :element-type (element-type listener))) @@ -253,7 +282,7 @@ setsockopt SO_REUSEADDR if :reuse is not nil" (let ((ll (string-tokens (substitute #\Space #\. dotted)))) (+ (ash (first ll) 24) (ash (second ll) 16) (ash (third ll) 8) (fourth ll))) - (ignore-error + (ignore-errors (let ((ll (string-tokens (substitute #\Space #\. dotted)))) (+ (ash (first ll) 24) (ash (second ll) 16) (ash (third ll) 8) (fourth ll))))))