This is the mail archive of the guile@cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

socket strangeness



Hello all--

I've a little nasty that's driving me crazy.  Under Guile 1.3 (2.1
glibc), the following small socket server drives me crazy (BTW:  I 
understand I've a huge security hole here. . .don't care 'bout that
yet).  

My problem is that the server accepts connections, but it can't
consistently (successful only the first 2-3 tries) write eval'd data
(or even just the data itself) to the port.  Now, if I make a large
datastream, ie (range 1 10000 1+ >), I may see _part_ of the socket
data before the socket is closed. 

I have several questions:
  
  1)  should close-port flush mysock automagically?  if not, should i 
      just flush-all-ports explicitly?
  2)  does display/write have a size "limit"?  IOW, should a reader
      expect a large datastream to be sent in chunks?

a more general question:

are there generally known strangenesses to be aware of when using
sockets under guile?

TIA.

--Brad

;;; sample server. . .shamelessly stolen from the FAQ
;;; BTW:  the FAQ example doesn't work on my machine :-(. . .the call
;;;       to read-line causes the interpreter to exit

(define portnum (string->number (cadr (command-line))))

(let ((port (socket AF_INET SOCK_STREAM 0)))
  (bind port AF_INET INADDR_ANY portnum)
  (listen port 10)                ; Queue up to 10 requests.
  (let loop ()
    (let ((p (accept port)))
      (let ((mysock (car p)))
	(let ((mydata (read mysock)))
	  (display (eval mydata) mysock))
	  (close-port mysock)))
    (loop)))




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]