doumao1917 2018-07-06 09:54
浏览 43

转到网络拨号问题

I'm having some issues connecting to a local golang TLS server via tls.dial or net.dial. The server ist started with the address localhost:10001 and I am able to connect to it with netcat (simply netcat localhost 10001 ) but trying it with golangs's dial method doesn't work (connection refused). What could be the reason for this? One important thing to point out is that I'm testing it on a Debian VM where I deinstalled the network manager so I could configure the network interfaces myself (static ip). My guess is that net.dial has some issues finding the right interface but what does netcat do that golang's methods don't? I tried all different kinds of addresses on both sides (server on localhost, ::1, 127.0.0.1; client same). On my windows host system it works (so the issue is probably not with the server). Thanks in advance.

    conn, err := tls.Dial("tcp", h.IP+":"+h.Port, conf)
if err != nil {
    log.Println(err)
    return empty
}

// do cleanup
defer conn.Close()

d := Craft_PKG( data )


//write package
WriteChunks( conn, d )

this is the client code and this

    ln, err := tls.Listen("tcp", "localhost:"+(*port), config)
if err != nil {
    log.Println(err)
    return err
}
defer ln.Close()

for {
    conn, err := ln.Accept()
    if err != nil {
        log.Println(err)
        continue
    }
    // start the handler for every incoming connection
    go h(conn)
}

the server code. It is all very straightforward and works with netcat and in my Host system as I mentioned.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题
    • ¥15 (标签-Python|关键词-socket)
    • ¥15 keil里为什么main.c定义的函数在it.c调用不了
    • ¥50 切换TabTip键盘的输入法
    • ¥15 可否在不同线程中调用封装数据库操作的类