为什么这在DrRacket中有效,而在控制台中没有在Racket中有效? (R:未定义;)

时间:2014-01-17 02:46:21

标签: racket

此代码测试端口连接。为什么这在DrRacket中有效,但在从控制台上的球拍可执行文件(球拍 - >创建可执行文件......)中无效?

#lang racket
(require racket/tcp)
(define (tcp-open? host port)
  (with-handlers ((exn:fail:network? (lambda (e) #f)))
    (define-values (inp outp) (tcp-connect host port))
    (close-input-port inp)
    (close-output-port outp)
    #t))

在DrRacket中运行良好:

Welcome to DrRacket, version 5.3.2 [3m].
Language: racket [custom]; memory limit: 512 MB.
> (tcp-open? "www.racket-lang.org" 80)
#t

来自控制台的错误消息是:

Welcome to Racket v5.3.2.
> (require racket/tcp)
> (define (tcp-open? host port)
  (with-handlers ((exn:fail:network? (lambda (e) #f)))
    (define-values (inp outp) (tcp-connect host port))
    (close-input-port inp)
    (close-output-port outp)
    #t))
> (tcp-open? "www.racket-lang.org" 80)
R: undefined;
 cannot reference undefined identifier
  context...:
   C:\Program Files\Racket\collects\racket\private\misc.rkt:87:7

0 个答案:

没有答案