[gambit-list] open-tcp-server MacOSX
    François Magnan 
    francois.magnan at licef.teluq.uqam.ca
       
    Mon May 14 15:43:14 EDT 2007
    
    
  
Hi,
I found a strange behavior with open-tcp-server on MacOSX of  
GambitC4b20 and GambitC4b22. I was able to isolate the problem up to  
this point... Eval the following code
(define (rpc-server-start)
   (let ((rpc-command-queue (open-tcp-server 5000)))
     (thread-start!
      (make-thread
       (lambda ()
         (let loop ()
           (let ((incoming-connection (read rpc-command-queue)))
             (debug "Got connection\n")
             (serve-rpc-command incoming-connection)
             )
           (loop)))))
     rpc-command-queue))
(define (serve-rpc-command incoming-connection)
   (let* ((command (read-line incoming-connection)))
     (display (string-append command "\n") incoming-connection)
     (display "ok!\n\n" incoming-connection)
     (force-output incoming-connection)
     (close-port incoming-connection)))
(define (main)
   (rpc-server-start)
   (loop-indefinitely)
   )
(define (loop-indefinitely)
   (thread-sleep! 1)
   (loop-indefinitely))
(main)
Then in a Terminal type
telnet 127.0.0.1 5000
type something and then return.
You should see:
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
sdj
sdj
ok!
Now comment out the call to "loop-indefinitely" in the (main)  
function. If you try the telnet again it will not work...
This is not the case in the MingW (WinXP) versions.
It seems I cannot start a tcp-server in a thread and still get the  
read-eval-print loop.
Anybody can help?
Thank you,
Francois Magnan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20070514/27951675/attachment.htm>
    
    
More information about the Gambit-list
mailing list