V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
CupTools
V2EX  ›  Node.js

为什么 nodejs net.connect() 会 read ECONNRESET,然而 telnet 就没有问题

  •  
  •   CupTools · 2017-04-13 12:12:20 +08:00 · 4446 次点击
    这是一个创建于 2567 天前的主题,其中的信息可能已经有所发展或是发生改变。

    如题

    var client = net.connect(43, server, function() {
        client.write(domain + '\n', 'ascii')
    })
    

    yields

    { Error: read ECONNRESET
        at exports._errnoException (util.js:1050:11)
        at TCP.onread (net.js:581:26) code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }
    

    However,

    telnet xxxx 43
    

    yields

    telnet xxx 43
    Trying xxx...
    Connected to xxx.
    Escape character is '^]'.
    
    4 条回复    2017-04-16 22:14:13 +08:00
    fds
        1
    fds  
       2017-04-13 17:07:47 +08:00
    telnet 没写东西呀。为了一致,把 client.write() 删掉试试?
    CupTools
        2
    CupTools  
    OP
       2017-04-13 22:23:32 +08:00 via Android
    @fds telnet 是有写东西的 没放出来
    CupTools
        3
    CupTools  
    OP
       2017-04-14 00:04:41 +08:00
    😂 找到问题了 要'\r\n'不是'\n'
    polun
        4
    polun  
       2017-04-16 22:14:13 +08:00
    用`os.EOL`?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1265 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 18:04 · PVG 02:04 · LAX 11:04 · JFK 14:04
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.