🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.emacs
Article #9610

How to read one character at a time on process-socket

#9610
From: Carsten Ruseng Jakobsen
Date: Fri, 23 Feb 1990 15:35
53 lines
3030 bytes
I have a written a Hyper-text back-end server (HyperBase) which is
communicating via sockets. I am now writing an interface in emacs to
this server. I have succeded in sending simple argument's as 4 byte
integers from the server to emacs and converting them, and vice versa.
However when I'm trying to read a larger amount of data, the result
is that (accept-process-output) blocks. Instead of relying on this
function I would like to read ONE character from the process attached
to the socket. Does such function exist, or how can I read one character
at a time from the process-output (the stuff the server is writing
to the socket.)
If you have the answer please *e-mail* it to ruseng@iesd.auc.dk

The scenario look's like: 

  (setq read-proc(open-network-stream 
		  "read-sock" "READ-buffer" hostname read-port))
  (set-process-filter read-proc 'read-filter)
. . .
(defun hb-read ()
  "Read the DATA-field from mode ent_no and insert it to current buffer"
  (interactive)
  (progn 
    (setq ent_no (read-input "Entity-no : "))
    (process-send-string write-proc "\000\000\000\001") ;1 = READ
    (process-send-string write-proc 
	(int-to-string-4ch (string-to-int ent_no))) 
    (process-send-string 
	write-proc (int-to-string-4ch 517)) ; 517= Read the DATA-field
    (set-process-filter read-proc 'read-filter)
    (accept-process-output read-proc) ;BLOCKING (when filter <> nil)
   )	
; If the return value is zero then get the stuff, otherwise exit nil.
  (cond ((= 0 ret)(progn
	; read length of the data to be read
		    (set-process-filter read-proc 'receive-number)
		    (accept-process-output read-proc)
	; read the data
;		    (set-process-filter read-proc  'receive-string)
		    (accept-process-output read-proc)
		    (insert-string string-received); insert in current buffer
		    ))
	)
)

Thanx in advance
------------------------------------------------------------------------------
| Carsten Ruseng Jakobsen,ruseng@iesd.auc.dk    {...}!mcvax!dkuug!iesd!ruseng|
| Systems programmer                                                         |
|                                                                _  /        |
| Department of Mathematics and Computer Science               - / (         |
| Aalborg University (AUC)                                   /  |  \         |
| DENMARK                                                    A  U  C         |
------------------------------------------------------------------------------
Technical Details
Message-ID: <RUSENG.90Feb23163516@purple.iesd.auc.dk>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!ucsd!ucbvax!bloom-beacon!eru!luth!sunic!dkuug!iesd!purple!ruseng

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!ucsd!ucbvax!bloom-beacon!eru!luth!sunic!dkuug!iesd!purple!ruseng
From: ruseng@iesd.auc.dk (Carsten Ruseng Jakobsen)
Newsgroups: comp.emacs
Subject: How to read one character at a time on process-socket
Message-ID: <RUSENG.90Feb23163516@purple.iesd.auc.dk>
Date: 23 Feb 90 15:35:16 GMT
Sender: ruseng@iesd.auc.dk (Carsten Ruseng Jakobsen)
Distribution: comp.emacs
Organization: Mathematics and Computer Science, University of Aalborg
Lines: 53