• 如何用TcpListener同时监听多个网卡的IP地址


        其实很简单,把特定的IPAddress改成 IPAddress.any 就可以了.
                IPAddress ipAddr = IPAddress.Parse(ip);
                
    if (ip == "0.0.0.0")
                
    {
                    ipAddr 
    = IPAddress.Any;
                }


                
                IPEndPoint localEP 
    = new IPEndPoint(ipAddr, port);
                
    if (tcpListener != null)
                
    {
                    tcpListener.Stop();
                }


                tcpListener 
    = new TcpListener(localEP);
                  Thread t = new Thread(new ParameterizedThreadStart(this.ThreadListen));
                  t.Start(tcpListener);

  • 相关阅读:
    PhoneGap打包webApp
    mysql触发器实例说明
    mysql索引总结
    python:生成器
    python:装饰器
    python:局部变量与全局变量
    python:函数
    python:文件操作
    python:集合及其运算
    python:字符串常用函数
  • 原文地址:https://www.cnblogs.com/evlon/p/756806.html
Copyright © 2020-2023  润新知