Results 1 to 4 of 4
  1. #1
    varons666 is offline Member
    Join Date
    Jun 2011
    Posts
    2
    Rep Power
    0

    Default Urgent help understanding code

    hi guys

    im new to java

    i have a piece of code that i need understanding off, please explain to me what this code is doing exactly. thanks in advance

    package client;

    import e.b;
    import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.OutputStreamWriter;
    import java.io.PrintStream;
    import java.io.Writer;
    import java.net.Socket;
    import java.net.UnknownHostException;

    public class f
    {
    private static long jdField_for = 1800000L;
    private static String a = null;
    private static int jdField_try = -1;
    private static long jdField_new = 0L;
    private static String[] jdField_do = { "vir1a.toonel.net", "vir1a.toonel.net", "vir1a.toonel.net", "vir1b.toonel.net", "vir1b.toonel.net", "vir1b.toonel.net", "dub1.toonel.net", "dub1.toonel.net", "dub1.toonel.net" };
    private static int[] jdField_if = { 8081, 8080, 3128, 8081, 8080, 3128, 8081, 8080, 3128 };
    private static d[] jdField_int = null;

    public static void a(String[] paramArrayOfString, int[] paramArrayOfInt)
    {
    if (jdField_do.length != jdField_if.length)
    {
    System.out.print("\nInvalid master info...");
    System.exit(1);
    }
    jdField_do = paramArrayOfString;
    jdField_if = paramArrayOfInt;
    jdField_try = -1;
    jdField_new = 0L;
    if (jdField_do.length != jdField_if.length)
    {
    System.out.print("\nInvalid master info...");
    System.exit(1);
    }
    }

    // ERROR //
    private static Socket a(String paramString, int paramInt)
    throws UnknownHostException, IOException
    {
    // Byte code:
    // 0: invokestatic 80 e/b:a ()Ljava/lang/String;
    // 3: ldc 82
    // 5: if_acmpne +13 -> 18
    // 8: new 84 java/net/Socket
    // 11: dup
    // 12: aload_0
    // 13: iload_1
    // 14: invokespecial 87 java/net/Socket:<init> (Ljava/lang/String;I)V
    // 17: areturn
    // 18: getstatic 90 e/b:D Ljava/lang/String;
    // 21: ifnull +319 -> 340
    // 24: ldc 92
    // 26: astore_2
    // 27: ldc 92
    // 29: astore_3
    // 30: aconst_null
    // 31: astore 4
    // 33: aconst_null
    // 34: astore 5
    // 36: aconst_null
    // 37: astore 6
    // 39: iconst_0
    // 40: istore 7
    // 42: new 84 java/net/Socket
    // 45: dup
    // 46: invokestatic 95 e/b:jdField_new ()Ljava/lang/String;
    // 49: invokestatic 99 e/b:jdField_do ()I
    // 52: invokespecial 87 java/net/Socket:<init> (Ljava/lang/String;I)V
    // 55: astore 6
    // 57: new 101 java/io/BufferedReader
    // 60: dup
    // 61: new 103 java/io/InputStreamReader
    // 64: dup
    // 65: aload 6
    // 67: invokevirtual 107 java/net/Socket:getInputStream ()Ljava/io/InputStream;
    // 70: invokespecial 110 java/io/InputStreamReader:<init> (Ljava/io/InputStream;)V
    // 73: invokespecial 113 java/io/BufferedReader:<init> (Ljava/io/Reader;)V
    // 76: astore 4
    // 78: new 115 java/io/BufferedWriter
    // 81: dup
    // 82: new 117 java/io/OutputStreamWriter
    // 85: dup
    // 86: aload 6
    // 88: invokevirtual 121 java/net/Socket:getOutputStream ()Ljava/io/OutputStream;
    // 91: invokespecial 124 java/io/OutputStreamWriter:<init> (Ljava/io/OutputStream;)V
    // 94: invokespecial 127 java/io/BufferedWriter:<init> (Ljava/io/Writer;)V
    // 97: astore 5
    // 99: aload 5
    // 101: new 129 java/lang/StringBuffer
    // 104: dup
    // 105: invokestatic 80 e/b:a ()Ljava/lang/String;
    // 108: invokestatic 133 java/lang/String:valueOf (Ljava/lang/Object;)Ljava/lang/String;
    // 111: invokespecial 135 java/lang/StringBuffer:<init> (Ljava/lang/String;)V
    // 114: ldc 137
    // 116: invokevirtual 141 java/lang/StringBuffer:append (Ljava/lang/String;)Ljava/lang/StringBuffer;
    // 119: aload_0
    // 120: invokevirtual 141 java/lang/StringBuffer:append (Ljava/lang/String;)Ljava/lang/StringBuffer;
    // 123: ldc 143
    // 125: invokevirtual 141 java/lang/StringBuffer:append (Ljava/lang/String;)Ljava/lang/StringBuffer;
    // 128: iload_1
    // 129: invokevirtual 146 java/lang/StringBuffer:append (I)Ljava/lang/StringBuffer;
    // 132: ldc 148
    // 134: invokevirtual 141 java/lang/StringBuffer:append (Ljava/lang/String;)Ljava/lang/StringBuffer;
    // 137: invokevirtual 151 java/lang/StringBuffer:toString ()Ljava/lang/String;
    // 140: invokevirtual 156 java/io/Writer:write (Ljava/lang/String;)V
    // 143: aload 5
    // 145: invokevirtual 159 java/io/BufferedWriter:newLine ()V
    // 148: getstatic 90 e/b:D Ljava/lang/String;
    // 151: ldc 92
    // 153: if_acmpeq +16 -> 169
    // 156: aload 5
    // 158: getstatic 90 e/b:D Ljava/lang/String;
    // 161: invokevirtual 156 java/io/Writer:write (Ljava/lang/String;)V
    // 164: aload 5
    // 166: invokevirtual 159 java/io/BufferedWriter:newLine ()V
    // 169: aload 5
    // 171: invokevirtual 159 java/io/BufferedWriter:newLine ()V
    // 174: aload 5
    // 176: invokevirtual 162 java/io/BufferedWriter:flush ()V
    // 179: aload 4
    // 181: invokevirtual 165 java/io/BufferedReader:readLine ()Ljava/lang/String;
    // 184: astore_2
    // 185: aload_2
    // 186: ifnonnull +6 -> 192
    // 189: goto +35 -> 224
    // 192: new 129 java/lang/StringBuffer
    // 195: dup
    // 196: aload_3
    // 197: invokestatic 133 java/lang/String:valueOf (Ljava/lang/Object;)Ljava/lang/String;
    // 200: invokespecial 135 java/lang/StringBuffer:<init> (Ljava/lang/String;)V
    // 203: aload_2
    // 204: invokevirtual 141 java/lang/StringBuffer:append (Ljava/lang/String;)Ljava/lang/StringBuffer;
    // 207: getstatic 168 e/b:y Ljava/lang/String;
    // 210: invokevirtual 141 java/lang/StringBuffer:append (Ljava/lang/String;)Ljava/lang/StringBuffer;
    // 213: invokevirtual 151 java/lang/StringBuffer:toString ()Ljava/lang/String;
    // 216: astore_3
    // 217: aload_2
    // 218: invokevirtual 171 java/lang/String:length ()I
    // 221: ifne -42 -> 179
    // 224: aload_2
    // 225: ifnonnull +11 -> 236
    // 228: new 74 java/io/IOException
    // 231: dup
    // 232: invokespecial 172 java/io/IOException:<init> ()V
    // 235: athrow
    // 236: aload_3
    // 237: ldc 174
    // 239: invokevirtual 178 java/lang/String:indexOf (Ljava/lang/String;)I
    // 242: iconst_m1
    // 243: if_icmpeq +94 -> 337
    // 246: iconst_1
    // 247: istore 7
    // 249: aload 6
    // 251: astore 10
    // 253: jsr +35 -> 288
    // 256: aload 10
    // 258: areturn
    // 259: goto +78 -> 337
    // 262: pop
    // 263: new 72 java/net/UnknownHostException
    // 266: dup
    // 267: invokespecial 179 java/net/UnknownHostException:<init> ()V
    // 270: athrow
    // 271: pop
    // 272: new 74 java/io/IOException
    // 275: dup
    // 276: invokespecial 172 java/io/IOException:<init> ()V
    // 279: athrow
    // 280: astore 9
    // 282: jsr +6 -> 288
    // 285: aload 9
    // 287: athrow
    // 288: astore 8
    // 290: iload 7
    // 292: ifne +13 -> 305
    // 295: aload 4
    // 297: ifnull +8 -> 305
    // 300: aload 4
    // 302: invokevirtual 182 java/io/BufferedReader:close ()V
    // 305: iload 7
    // 307: ifne +13 -> 320
    // 310: aload 5
    // 312: ifnull +8 -> 320
    // 315: aload 5
    // 317: invokevirtual 183 java/io/BufferedWriter:close ()V
    // 320: iload 7
    // 322: ifne +13 -> 335
    // 325: aload 6
    // 327: ifnull +8 -> 335
    // 330: aload 6
    // 332: invokevirtual 184 java/net/Socket:close ()V
    // 335: ret 8
    // 337: jsr -49 -> 288
    // 340: aconst_null
    // 341: areturn
    //
    // Exception table:
    // from to target type
    // 42 262 262 java/net/UnknownHostException
    // 42 262 271 java/io/IOException
    // 42 256 280 finally
    // 259 280 280 finally
    // 337 340 280 finally
    }

    private static synchronized int jdField_if(Socket paramSocket)
    throws UnknownHostException, IOException
    {
    if (b.a() == "NONE")
    {
    b.D = null;
    return 1;
    }
    if (b.D != null)
    return 1;
    int i = 0;
    int j = 0;
    String str1 = "";
    String str2 = "";
    int k = 0;
    while (k < jdField_do.length)
    {
    Socket localSocket = null;
    BufferedReader localBufferedReader = null;
    BufferedWriter localBufferedWriter1 = null;
    null;
    BufferedWriter localBufferedWriter2 = null;
    try
    {
    localSocket = new Socket(b.jdField_new(), b.jdField_do());
    localBufferedReader = new BufferedReader(new InputStreamReader(localSocket.getInputStream()));
    localBufferedWriter1 = new BufferedWriter(new OutputStreamWriter(localSocket.getOutputStream())) ;
    localBufferedWriter2 = new BufferedWriter(new OutputStreamWriter(paramSocket.getOutputStream())) ;
    new BufferedReader(new InputStreamReader(paramSocket.getInputStream()));
    j = str2.indexOf("Proxy-Authorization");
    if (j != -1)
    {
    str1 = str2.substring(j, str2.indexOf(b.y, j));
    b.D = str1;
    i = 1;
    }
    else
    {
    localBufferedWriter1.write(b.a() + " " + jdField_do[k] + ":" + jdField_if[k] + " HTTP/1.1");
    localBufferedWriter1.newLine();
    localBufferedWriter1.newLine();
    localBufferedWriter1.flush();
    str2 = "";
    do
    {
    str1 = localBufferedReader.readLine();
    if (str1 == null)
    break;
    str2 = str2 + str1 + b.y;
    }
    while (str1.length() != 0);
    if (str1 == null)
    {
    i = 0;
    }
    else if (str2.indexOf(" 200 Connection established") != -1)
    {
    b.D = "";
    i = 1;
    }
    else if (str2.indexOf(" 407 Access Denied") != -1)
    {
    localBufferedWriter2.write(str2);
    localBufferedWriter2.flush();
    i = 2;
    }
    else
    {
    i = -1;
    }
    }
    }
    catch (UnknownHostException localUnknownHostException)
    {
    throw new UnknownHostException();
    }
    catch (IOException localIOException)
    {
    throw new IOException();
    }
    finally
    {
    if (localBufferedReader != null)
    localBufferedReader.close();
    if (localBufferedWriter1 != null)
    localBufferedWriter1.close();
    if (localSocket != null)
    localSocket.close();
    if (i != -1)
    return i;
    ret;
    }
    }
    return i;
    }

    public static final synchronized Socket a(Socket paramSocket)
    {
    Socket localSocket = null;
    int i = 0;
    try
    {
    i = jdField_if(paramSocket);
    }
    catch (Exception localException1)
    {
    localException1.printStackTrace();
    }
    if (i != 1)
    return null;
    if ((jdField_try != -1) && (System.currentTimeMillis() - jdField_new < jdField_for))
    try
    {
    localSocket = a(a, jdField_try);
    }
    catch (Exception localException2)
    {
    localSocket = null;
    }
    if (localSocket != null)
    return localSocket;
    d.jdField_if();
    jdField_int = new d[jdField_do.length];
    for (int j = 0; j < jdField_do.length; j++)
    jdField_int[j] = new d(jdField_do[j], jdField_if[j]);
    for (j = 0; j < jdField_do.length; j++)
    jdField_int[j].start();
    while (true)
    {
    for (j = 0; j < jdField_do.length; j++)
    if (!jdField_int[j].a)
    break;
    localSocket = d.a();
    if (localSocket != null)
    {
    jdField_new = System.currentTimeMillis();
    a = d.jdField_int;
    jdField_try = d.jdField_if;
    jdField_int = null;
    System.gc();
    return localSocket;
    }
    if (j == jdField_do.length)
    return null;
    try
    {
    Thread.sleep(10L);
    }
    catch (InterruptedException localInterruptedException)
    {
    }
    }
    }
    }

  2. #2
    varons666 is offline Member
    Join Date
    Jun 2011
    Posts
    2
    Rep Power
    0

    Default

    yoh, its alittle long, please explain the first parts atleast, thanx

  3. #3
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default

    What don't you understand about it? And what makes you think that marking your thread is urgent is going to get you help any sooner? (in fact, far from it - sorry to say but your time isn't any more valuable than any other person on these forums)

    Suggested Reading: How To Ask Questions The Smart Way

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,651
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by varons666 View Post
    if (b.a() == "NONE")
    I didn´t read through all that code (it's much too long and the disassembled code is irrelevant) but I almost immediately noticed the above line. It is almost definitely wrong. Read the API documentation for the String class to see how Strings need to be compared.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. need help understanding part of code
    By mustachMan in forum New To Java
    Replies: 7
    Last Post: 02-09-2011, 07:11 PM
  2. Replies: 9
    Last Post: 09-21-2010, 04:15 PM
  3. trouble understanding code help
    By yasmin k in forum New To Java
    Replies: 4
    Last Post: 11-16-2009, 09:46 PM
  4. code HELP URGENT
    By NickkicN in forum New To Java
    Replies: 1
    Last Post: 08-14-2008, 05:43 PM
  5. Urgent small code
    By karingulanagaraj in forum New To Java
    Replies: 7
    Last Post: 08-11-2008, 04:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •