/*
 * Decompiled with CFR 0_110.
 * 
 * Could not load the following classes:
 *  java.io.IOException
 *  java.lang.Exception
 *  java.lang.Math
 *  java.lang.Object
 *  java.lang.String
 *  java.net.DatagramPacket
 *  java.net.DatagramSocket
 *  java.net.InetAddress
 */
package com.xinli.portalclient.util;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class SocketClientUDP {
    private byte[] buffer = new byte[4096];
    private DatagramSocket ds = new DatagramSocket();

    public static byte[] getAuth(int n) {
        int n2 = 0;
        byte[] arrby = new byte[n];
        int n3 = 0;
        while (n3 < n) {
            arrby[n2] = (byte)(100.0 * Math.random() % 255.0);
            ++n2;
            ++n3;
        }
        return arrby;
    }

    public static byte[] intToByteArray(int n, int n2) {
        byte[] arrby = new byte[n2];
        int n3 = 0;
        while (n3 < n2) {
            arrby[n3] = (byte)(255 & n >>> 8 * (-1 + arrby.length - n3));
            ++n3;
        }
        return arrby;
    }

    public final void close() {
        try {
            this.ds.close();
            return;
        }
        catch (Exception var1_1) {
            var1_1.printStackTrace();
            return;
        }
    }

    public final int getSoTimeout() throws Exception {
        return this.ds.getSoTimeout();
    }

    public final DatagramSocket getSocket() {
        return this.ds;
    }

    public final String receive(String string2, int n) throws Exception {
        DatagramPacket datagramPacket = new DatagramPacket(this.buffer, this.buffer.length);
        this.ds.receive(datagramPacket);
        return new String(datagramPacket.getData(), 0, datagramPacket.getLength(), "GBK");
    }

    public final DatagramPacket send(String string2, int n, byte[] arrby) throws IOException {
        DatagramPacket datagramPacket = new DatagramPacket(arrby, arrby.length, InetAddress.getByName((String)string2), n);
        this.ds.send(datagramPacket);
        return datagramPacket;
    }

    public final void setSoTimeout(int n) throws Exception {
        this.ds.setSoTimeout(n);
    }
}

