Android Socket Create getSocket(Context context, String proxyHost, int proxyPort)

Here you can find the source of getSocket(Context context, String proxyHost, int proxyPort)

Description

get Socket

Declaration

public static Socket getSocket(Context context, String proxyHost,
            int proxyPort) throws IOException 

Method Source Code

//package com.java2s;
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;
    }/*from  w ww  .j  ava 2s. c  om*/

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

    }
}

Related

  1. getSocket(Context context)