[plt-scheme] Reading on TCP ports and #<eof>

From: Erich Rast (erich at snafu.de)
Date: Thu Jul 19 09:15:12 EDT 2007

>
> Can you say more about the way that TCP connections are created in  
> your
> program?

The code implements a custom protocol that is already spread across  
several files (it works with pipes, though). So it's difficult to  
provide a simplified example, I'm afraid. Here is how the server is  
started and a client connects:

  (define (transmitter-connect t)
     (case (transmitter-protocol t)
       ((tcp tcp/ip) (let-values (((in out) (tcp-connect (transmitter- 
address t) (transmitter-port t))))
                       (let ((connection (make-connection  
(transmitter-make-name t in out #f) in out)))
                         (connection-start-client-listen connection)
                         (array-add! (transmitter-connections t)  
connection)
                         connection)))
       (else (error "transmitter '~s' specifies unsupported protocol:  
~s" (transmitter-name t) (transmitter-protocol t)))))

   (define/kw (transmitter-start-server t commands
                                        #:optional
                                        (conn-timeout #f)
                                        (max-memory 10000000)
                                        (max-client-input-errors 50)
                                        (max-unsupported-commands 50)
                                        (max-interactions +inf.0))
     (case (transmitter-protocol t)
       ((tcp tcp/ip) (thread
                      (lambda ()
                        (run-server
                         (transmitter-port t)
                         (lambda (in-port out-port)
                           (let ((connection (make-connection  
(transmitter-make-name t in-port out-port #t) in-port out-port)))
                             (connection-start-server connection  
commands
                                                      max-memory max- 
client-input-errors
                                                      max-unsupported- 
commands
                                                      max-interactions)
                             (array-add! (transmitter-connections t)  
connection)))
                         conn-timeout))))
       (else (error "transmitter '~s' specifies unsupported protocol:  
~s" (transmitter-name t) (transmitter-protocol t)))))

I suppose it's a problem with my protocol implementation, but perhaps  
you can see a problem with tcp-connect or run-server (from  
"thread.ss") above?

Regards,

Erich




Posted on the users mailing list.