package B;

import A.AInterfaceRomeo;
import G.R;
import G.l;
import bH.D;
import bS.AInterfaceRomeo;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.logging.Level;
import java.util.logging.Logger;

public class BInterfaceSierra extends o implements AInterfaceRomeo {
  c k;
  
  boolean l = true;
  
  R m;
  
  public BInterfaceSierra(R paramR) {
    this.m = paramR;
    this.k = new c(paramR);
    a(true);
    c(30000);
  }
  
  public AInterfaceRomeo v() {
    this.l = true;
    this.k.b(z());
    this.k.a("UDP");
    this.k.b();
    try {
      this.c = InetAddress.getLocalHost().getHostAddress();
    } catch (UnknownHostException unknownHostException) {
      Logger.getLogger(s.class.getName()).log(Level.SEVERE, (String)null, unknownHostException);
      throw new l("failed to get localhost ip address");
    } 
    if (this.c == null || this.c.equals(""))
      throw new l("IP Address or host name not set! Can not open UDP "); 
    if (this.d <= 0)
      throw new l("Invalid Port:" + this.d + " Can not open UDP "); 
    c();
    try {
      D.c("Opening UDP Server listener: " + y());
      s s1 = new s(this.m);
      for (AInterfaceRomeo r1 : l()) {
        try {
          s1.a(r1.c(), a(r1.c()));
        } catch (A.s s2) {
          Logger.getLogger(m.class.getName()).log(Level.WARNING, "Failed to set Setting", (Throwable)s2);
        } 
      } 
      s1.a(true);
      DatagramSocket datagramSocket = s1.t();
      byte[] arrayOfByte = new byte[50];
      DatagramPacket datagramPacket = new DatagramPacket(arrayOfByte, arrayOfByte.length);
      datagramSocket.setSoTimeout(5000);
      datagramSocket.setTrafficClass(20);
      int i = 0;
      do {
        try {
          datagramSocket.receive(datagramPacket);
          i = datagramPacket.getLength();
          D.c("bytesRecieved = " + i);
        } catch (Exception exception) {
          if (this.l)
            D.d("No Connection on UDP, try again."); 
          i = 0;
        } 
      } while (this.l && i <= 0);
      if (datagramPacket.getLength() > 0) {
        s1.a(datagramSocket);
        byte[] arrayOfByte1 = new byte[datagramPacket.getLength()];
        System.arraycopy(arrayOfByte, 0, arrayOfByte1, 0, arrayOfByte1.length);
        s1.f.a(arrayOfByte1);
        s1.g.a(datagramPacket.getAddress());
        s1.g.a(datagramPacket.getPort());
        s1.b(3);
        s1.a();
        return s1;
      } 
    } catch (IOException iOException) {
      g();
      D.a(iOException);
    } finally {
      this.k.a();
    } 
    return null;
  }
  
  public void w() {
    this.l = false;
  }
  
  public int s() {
    return 2;
  }
  
  public int x() {
    return 1;
  }
}


/* Location:              /home/rewrich/Downloads/TunerStudioMS/TunerStudioMS/!/B/s.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */