Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.io.IOException;

import java.net.InetSocketAddress;
import java.net.Socket;

import android.content.Context;

public class Main {
    private final static String DEFAULT_HOST = "127.0.0.1";
    private final static int DEFAULT_SOCKET_PORT = 9050;

    public static Socket getSocket(Context context, String proxyHost, int proxyPort) throws IOException {
        Socket sock = new Socket();

        sock.connect(new InetSocketAddress(proxyHost, proxyPort), 10000);

        return sock;
    }

    public static Socket getSocket(Context context) throws IOException {
        return getSocket(context, DEFAULT_HOST, DEFAULT_SOCKET_PORT);

    }
}