有时需要指定网络通信时本地使用的IP地址和端口号. 在Go语言中可通过定义 Dialer 中LocalAddr 成员实现. Dialer结构定义如下: // A Dialer contains options for connecting to an address. // // The zero value for each field is equivalent to dialing // without that option. Dialing with the zero value of…
以下是从stackoverflow上抄下来的,很有帮助 How can you have a TCP connection back to the same port? A TCP connection is uniquely identified by this tuple (local address, local port #, foreign address, foreign port #). There is no requirement that local address and …