I am currently trying to use racket/tcp library in a TR program and used 
require/typed to import the necessary functions as I could not find this 
provided with TR by default. However, the following code has a problem when it 
runs:

#lang typed/racket

(require/typed racket/tcp
               [opaque TCP-Listener tcp-listener?]
               [tcp-listen (-> Number TCP-Listener)]
               [tcp-accept (-> TCP-Listener (Values Number Number))])

(: server (-> Number Void))
(define (server port)
  (let ([listener (tcp-listen port)])
    (define-values (inp outp) (tcp-accept listener))
    (displayln inp)
    (displayln outp)))

The code compiles fine but while running the "server" function with a valid 
port it errors out:

 tcp-listen: broke its own contract
  promised: tcp-listener?
  produced: #<tcp-listener>
  in: (-> any/c tcp-listener?)
  contract from: (interface for tcp-listen)
  blaming: (interface for tcp-listen)
   (assuming the contract is correct)
  at: unsaved-editor:5.16

I am not sure what exactly this error message means as tcp-listener is creating 
a valid listener as given by "produced: #<tcp-listener>" but still the 
predicate seems to be failing. The program runs fine with #lang racket. Any 
help?

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to