// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

import java.io.*;
import java.net.Socket;
import sign.signlink;

public class Class12
    implements Runnable
{

    public Class12(byte byte0, Applet_Sub1 applet_sub1, Socket socket)
        throws IOException
    {
        aBoolean206 = false;
        aBoolean210 = false;
        aBoolean215 = false;
        aBoolean216 = false;
        anApplet_Sub1_211 = applet_sub1;
        aSocket209 = socket;
        aSocket209.setSoTimeout(30000);
        aSocket209.setTcpNoDelay(true);
        anInputStream207 = aSocket209.getInputStream();
        anOutputStream208 = aSocket209.getOutputStream();
        if(byte0 != -87)
            aBoolean206 = !aBoolean206;
    }

    public void method205()
    {
        aBoolean210 = true;
        try
        {
            if(anInputStream207 != null)
                anInputStream207.close();
            if(anOutputStream208 != null)
                anOutputStream208.close();
            if(aSocket209 != null)
                aSocket209.close();
        }
        catch(IOException _ex)
        {
            System.out.println("Error closing stream");
        }
        aBoolean215 = false;
        synchronized(this)
        {
            notify();
        }
        aByteArray212 = null;
    }

    public int method206()
        throws IOException
    {
        if(aBoolean210)
            return 0;
        else
            return anInputStream207.read();
    }

    public int method207()
        throws IOException
    {
        if(aBoolean210)
            return 0;
        else
            return anInputStream207.available();
    }

    public void method208(byte abyte0[], int i, int j)
        throws IOException
    {
        if(aBoolean210)
            return;
        int k;
        for(; j > 0; j -= k)
        {
            k = anInputStream207.read(abyte0, i, j);
            if(k <= 0)
                throw new IOException("EOF");
            i += k;
        }

    }

    public void method209(int i, boolean flag, byte abyte0[], int j)
        throws IOException
    {
        if(aBoolean210)
            return;
        if(aBoolean216)
        {
            aBoolean216 = false;
            throw new IOException("Error in writer thread");
        }
        if(aByteArray212 == null)
            aByteArray212 = new byte[5000];
        synchronized(this)
        {
            for(int k = 0; k < j; k++)
            {
                aByteArray212[anInt214] = abyte0[k + i];
                anInt214 = (anInt214 + 1) % 5000;
                if(anInt214 == (anInt213 + 4900) % 5000)
                    throw new IOException("buffer overflow");
            }

            if(!aBoolean215)
            {
                aBoolean215 = true;
                anApplet_Sub1_211.method12(this, 3);
            }
            notify();
        }
        if(!flag);
    }

    public void run()
    {
        while(aBoolean215) 
        {
            int i;
            int j;
            synchronized(this)
            {
                if(anInt214 == anInt213)
                    try
                    {
                        wait();
                    }
                    catch(InterruptedException _ex) { }
                if(!aBoolean215)
                    return;
                j = anInt213;
                if(anInt214 >= anInt213)
                    i = anInt214 - anInt213;
                else
                    i = 5000 - anInt213;
            }
            if(i > 0)
            {
                try
                {
                    anOutputStream208.write(aByteArray212, j, i);
                }
                catch(IOException _ex)
                {
                    aBoolean216 = true;
                }
                anInt213 = (anInt213 + i) % 5000;
                try
                {
                    if(anInt214 == anInt213)
                        anOutputStream208.flush();
                }
                catch(IOException _ex)
                {
                    aBoolean216 = true;
                }
            }
        }
    }

    public void method210(boolean flag)
    {
        System.out.println("dummy:" + aBoolean210);
        System.out.println("tcycl:" + anInt213);
        if(flag)
        {
            for(int i = 1; i > 0; i++);
        }
        System.out.println("tnum:" + anInt214);
        System.out.println("writer:" + aBoolean215);
        System.out.println("ioerror:" + aBoolean216);
        try
        {
            System.out.println("available:" + method207());
            return;
        }
        catch(IOException _ex)
        {
            return;
        }
    }

    public boolean aBoolean206;
    public InputStream anInputStream207;
    public OutputStream anOutputStream208;
    public Socket aSocket209;
    public boolean aBoolean210;
    public Applet_Sub1 anApplet_Sub1_211;
    public byte aByteArray212[];
    public int anInt213;
    public int anInt214;
    public boolean aBoolean215;
    public boolean aBoolean216;
}
