Ipop.Ethernet.Ethernet C# (CSharp) Method

Ethernet() public method

Initializes the Ethernet device by opening the TAP device and starting the ISource thread.
public Ethernet ( string device_name ) : Brunet
device_name string
return Brunet
    public Ethernet(string device_name)
    {
      for(int i = 0; i < 15; i++) {
        try {
          _tap = Ipop.Tap.TapDevice.GetTapDevice(device_name);
          break;
        } catch {}
        Thread.Sleep(2);
        ProtocolLog.WriteIf(ProtocolLog.Exceptions,
            "Unable to set up the tap, trying again...");
      }

      if(_tap == null) {
        ProtocolLog.WriteIf(ProtocolLog.Exceptions, "Unable to set up the tap.");
        Environment.Exit(1);
      }

      Address = _tap.Address;

      _running = true;
      _read_thread = new Thread(ReadLoop);
      _read_thread.IsBackground = true;
      _read_thread.Start();
    }