FileDocCategorySizeDatePackage
SocketConnect.javaAPI DocAndroid 5.1 API1352Thu Mar 12 22:22:42 GMT 2015com.android.proxyhandler

SocketConnect

public class SocketConnect extends Thread
hide

Fields Summary
private InputStream
from
private OutputStream
to
Constructors Summary
public SocketConnect(Socket from, Socket to)

        this.from = from.getInputStream();
        this.to = to.getOutputStream();
        start();
    
Methods Summary
public static voidconnect(java.net.Socket first, java.net.Socket second)

        try {
            SocketConnect sc1 = new SocketConnect(first, second);
            SocketConnect sc2 = new SocketConnect(second, first);
            try {
                sc1.join();
            } catch (InterruptedException e) {
            }
            try {
                sc2.join();
            } catch (InterruptedException e) {
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    
public voidrun()

        final byte[] buffer = new byte[512];

        try {
            while (true) {
                int r = from.read(buffer);
                if (r < 0) {
                    break;
                }
                to.write(buffer, 0, r);
            }
            from.close();
            to.close();
        } catch (IOException io) {

        }