.Net Socket 多网卡下指定网卡/绑定网卡发送数据

            IPEndPoint serverIPE = new IPEndPoint(IPAddress.Parse("server ip"), 80);
            IPEndPoint localIPE = new IPEndPoint(IPAddress.Parse("192.168.1.2"), 6639);
            Socket socket = new Socket(serverIPE.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
            socket.Bind(localIPE);//就是这句了
            socket.Connect(serverIPE);

  其实就是开始连接前多Bind一下,C++下也有类似绑定。

posted @ 2012-10-22 18:08 zzmsl 阅读(...) 评论(...) 编辑 收藏