[Prev][Next][Index][Thread]
TCP 4K Write Buffer
Folks,
I'm trying to use mac tcp to communicate between CL-HTTP and a Java
applet. The applet sends me characters OK but when I try to write them
back they seem to get buffered until 4K have been accumulated, then they
get sent.
I am calling STREAM-FORCE-OUTPUT on the stream. When I inspect the strea
the WRITE-COUNT field goes to zero, but the characters do not get to Java.
Below is the Lisp code I am using. If anyone can help solve this problem,
I would be grateful.
-Chris Eliot
;;;Tests the ability of Lisp to listen on a socket.
;;;Type (setup-echo-socket nil 123 3) and it will wait for some client to
;;;call up on the given port number, and then it will echo back forms.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Echo Sockets for Testing ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar *java-enable* t)
(defvar *java-communication-processes* nil)
(defvar *java-stream* nil) ; Last one that talked to me.
(defun java-data-ready (socket)
(or (listen socket)
(null *java-enable*)))
(defun echo-socket (host port)
(let ((socket (open-tcp-stream host port)))
(unwind-protect
(loop while (not (stream-eofp socket))
do (process-wait "JAVA Needed" #'java-data-ready socket)
do (setq *java-stream* socket)
if (null *java-enable*)
return nil
do (let ((chr (read-char socket nil :eof)))
(if (eq chr #\null)
(format t "$")
(format t "~c" chr))
(write-char chr socket))
do (stream-force-output socket)
)
(stream-close socket))
))
(defun setup-echo-sockets (host port count)
(setq *java-enable* t)
(loop for i from 1 to count
for process = (process-run-function
(format nil "JAVA SOCKET ~s" i)
#'echo-socket host port)
;; Make a list of the processes, so that we can later check on
;; them to determine if they are still alive. Currently, I am
;; not sure what is the best way to do that check.
do (push process *java-communication-processes*)))
(defun close-echo-sockets ()
(setq *java-enable* nil))
(setup-echo-sockets nil 123 3)
Christopher R. Eliot, Senior Postdoctoral Research Associate
Center for Knowledge Communication, Department of Computer Science
University of Massachusetts, Amherst. (413) 545-4248 FAX: 545-1249
ELIOT@cs.umass.edu, http://rastelli.cs.umass.edu/~ckc/people/eliot/