Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
byte[] fileNameByte = Encoding.ASCII.GetBytes(e.FullPath);
      byte[] fileData = File.ReadAllBytes(e.FullPath);
      byte[] clientData = new byte[4 + e.Name.Length + fileData.Length];
      byte[] fileNameLen = BitConverter.GetBytes(fileNameByte.Length);
      m_socWorker = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
      String szIPSelected = "192.168.0.1";
      String szPort = "33333";
      try
      {
          int alPort = System.Convert.ToInt16(szPort, 10);
          System.Net.IPAddress remoteIPAddress = System.Net.IPAddress.Parse(szIPSelected);
          System.Net.IPEndPoint remoteEndPoint = new System.Net.IPEndPoint(remoteIPAddress, alPort);
          m_socWorker.Connect(remoteEndPoint);
      }
      catch (System.Net.Sockets.SocketException se)
      {
          Console.WriteLine(se.Message);
      }
Posted

1 solution

You don't. The NIC is chosen based on the route to the destination IP Address.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900