;;; -*- Syntax: Ansi-Common-Lisp; Base: 10; Mode: lisp; Package: clit -*-
-;;; $Id: compat.lisp,v 1.2 2003/07/08 08:34:22 kevin Exp $
+;;; $Id: compat.lisp,v 1.3 2003/07/08 12:10:16 kevin Exp $
(in-package #:modlisp)
#+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)))
(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)
#+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)))