package a.c.a.b;

import a.a.a.b;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class g extends h {
    private static final String u = "AOALocalServerSocketReadThread";
    public static final /* synthetic */ boolean v = true;
    private ServerSocket t = null;

    public g(int i, String str, int i2) {
        super(i, str, -1);
        try {
            this.t = new ServerSocket(i);
        } catch (Exception e) {
            b.b(u, "Create " + str + " fail.", e);
        }
        d(1);
        c(i2);
    }

    private void p() {
        int a2 = a(f());
        b(a2);
        b.d().a(f(), a2, 2, d());
    }

    @Override // a.c.a.b.h
    public void a() {
        ServerSocket serverSocket = this.t;
        if (serverSocket != null) {
            try {
                serverSocket.close();
            } catch (IOException e) {
                b.b(u, "Close " + h() + " server socket fail", e);
            }
        }
        super.a();
    }

    @Override // a.c.a.b.h
    public void m() {
        p();
    }

    @Override // a.c.a.b.h
    public Socket o() {
        try {
            if (this.t == null || !i()) {
                return null;
            }
            Socket accept = this.t.accept();
            if (accept == null) {
                b.a(u, "One client connected fail: " + h());
            }
            b.a(u, "One client connected in " + h());
            if (!v) {
                if (accept == null) {
                    throw new AssertionError();
                }
            }
            accept.setTcpNoDelay(true);
            accept.setSendBufferSize(327680);
            accept.setReceiveBufferSize(327680);
            return accept;
        } catch (Exception e) {
            b.b(u, "Get Exception in accept:" + h(), e);
            return null;
        }
    }
}
