亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? wapptr.java~353~

?? jwap 協(xié)議 udp 可以用于手機(jī)通訊
?? JAVA~353~
?? 第 1 頁(yè) / 共 5 頁(yè)
字號(hào):
package net.sourceforge.jwap;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2006</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
import java.io.*;
import java.net.*;
import java.util.*;

import net.sourceforge.jwap.http.*;
import net.sourceforge.jwap.util.*;
import net.sourceforge.jwap.util.wbxml.*;
import net.sourceforge.jwap.wsp.*;
import net.sourceforge.jwap.wsp.pdu.*;
import net.sourceforge.jwap.wtp.*;
import org.apache.xml.serialize.*;
import org.w3c.dom.*;

/**
 * This class represents a WSP "User-Agent" which can be used for executing
 * WSP <code>GET</code> and <code>POST</code> methods.
 * <p>
 * <h3>Example</h3>
 * <pre>
 * WAPClient client = new WAPClient("localhost", 9201);
 * Request request = new GetRequest("http://localhost/");
 * client.connect();
 * Response response = client.execute(request);
 * client.disconnect();
 * </pre>
 * @author Michel Marti
 *
 */
public class WapPtr {

    /** Default connect/disconnect timeout in milliseconds: 30000 */
    public static final long DEFAULT_CONNECT_TIMEOUT = 10000;
    /** Default execute timeout in milliseconds: 500000 */
    public static final long DEFAULT_EXEC_TIMEOUT = 20000;

    public static final long DEFAULT_HTTP_TIMEOUT = 120000;

    private static final Logger log = Logger.getLogger(WapPtr.class);

    static {
        Logger.initLogSystem(true);
    }

    private static final String USAGE =
            "Usage: WAPClient <WAP-Gateway-address[:port]> [GET/POST] [options] <URL>\n" +
            "   if method (GET/POST) is unspecified, GET is assumed\n\n" +
            "   Common options:\n" +
            "      -u <user-agent>   The User-Agent (defaults to jWAP/1.x)\n" +
            "      -o <file>         write response to file\n" +
            "      -l [addr]:port    local port (and address) to bind to\n" +
            "      -tc <timeout>     connection timeout (seconds, default=30)\n" +
            "      -tx <timeout>     request timeout (seconds, default=180)\n" +
            "      -v                show response-headers\n\n" +
            "   POST options:\n" +
            "      -c <content-type> The content-type  of the response body\n" +
            "      -p <file>         A file containing the post data, use '-' to read" +
            " the post data from standard input";

    private static final String DEFAULT_CONTENT_TYPE = "application/unknown";
    private static final String CONNECTED = "CONNECTED";

    private InetAddress gwAddr;
    private InetAddress localAddr;
    private int gwPort;
    private int localPort;
    private CWSPSession session;
    private HttpSession http_session;
    private Hurl http_url = null;
    private long disconnectTimeout;
    private int downloadflg = 0;

    private byte[] sessionLock = new byte[0];

    private IWSPUpperLayer2 upperLayerImpl;
    private HttpUpperLayer upperlayerhttp;
    private Hashtable pendingRequests;
    public FileWork filework = null;
    public String[] LogStr = {"0", "0", "0", "0", "0", "0", "0", "0", "0", "0",
                             "0", "0"};
    public String FileType = "wml";
    public String DownLoadFileName = "";
    public String AgentName = "Nokio";
    public int Sendflg = 0;
    public int downmms = 0;
    public int xhtml_wml = 0;
    public int waitfor = 0;
    public long downtime = 0;
    public int linkgate = 1;
    public WapPtr() {

    }

    /**
     * Construct a new WAP Client
     * @param wapGateway hostname of the WAP gateway to use
     * @param port port-number
     * @throws UnknownHostException if the hostname cannot be resolved
     */
    public WapPtr(String wapGateway, int port) throws UnknownHostException {
        this(InetAddress.getByName(wapGateway), port);
    }

    /**
     * Construct a new WAP Client
     * @param wapGateway the address of the WAP gateway to use
     * @param port the WAP gateway port number
     */
    public WapPtr(InetAddress wapGateway, int port) {
        this(wapGateway, port, null, CWTPSocket.DEFAULT_PORT);
    }

    /**
     * Construct a new WAP Client
     * @param wapGateway the addresss of the WAP gateway to use
     * @param wapPort the WAP gateway port number
     * @param localAddress the local address to bind to
     * @param localPort the local port to bind to (0 to let the OS pick a free port)
     */
    public WapPtr(InetAddress wapGateway, int wapPort,
                  InetAddress localAddress,
                  int localPort) {
        gwAddr = wapGateway;
        gwPort = wapPort;
        this.localAddr = localAddress;
        this.localPort = localPort;
        upperLayerImpl = new UpperLayerImpl();
        pendingRequests = new Hashtable();
        filework = new FileWork();

    }

    public WapPtr(InetAddress localAddress, int localPort, int type) {

        if (!ReadJwapConf()) {
            log.error("WapPtr 讀取配置文件失敗");
            System.exit(1);
        }

        this.localAddr = localAddress;
        this.localPort = localPort;
        upperLayerImpl = new UpperLayerImpl();
        pendingRequests = new Hashtable();
        filework = new FileWork();

    }


    /**
     * Execute a request. The client must be connected to the gateway.
     * @param request the request to execute
     * @return the response
     * @throws SocketException if a timeout occurred
     * @throws IllegalStateException if the client is not connected
     */
    public Response execute(Request request) throws SocketException,
            IllegalStateException {
        return execute(request, DEFAULT_EXEC_TIMEOUT);
    }


    /**
     * Execute a request. The client must be connected to the gateway.
     * @param request the request to execute
     * @param timeout timeout in milliseconds
     * @return the response
     * @throws SocketException if a timeout occurred
     * @throws IllegalStateException if the client is not connected
     */
    public int execute_http(Request request, long timeout) throws
            SocketException,
            IllegalStateException {
        int code = -1;
        String basheader = "";
        synchronized (this) {
            if (http_session == null) {
                throw new IllegalStateException("Not yet connected");
            }

            basheader = "User-Agent:" + AgentName + "\r\n";
            basheader = basheader + "Accept: www/source;text/html;" +
                        "application/vnd.wap.xhtml+xml;" +
                        "application/xhtml+xml;" +
                        "application/wml+xml; application/vnd.wap.wmlc;" +
                        "text/vnd.wap.wml; image/vnd.wap.wbmp; image/png; image/jpeg; image/gif; image/tiff; */*\r\n";

            if (request instanceof GetRequest) {
                System.out.println("Executing GET Request for URL " +
                                   request.getURL());
                if (log.isDebugEnabled()) {
                    log.debug("Executing GET Request for URL " + request.getURL());
                }
                try {
                    code = http_session.s_get(basheader, request.getURL());
                } catch (Exception ex) {
                }
            } else if (request instanceof PostRequest) {
                System.out.println("Executing POST Request for URL " +
                                   request.getURL());
                if (log.isDebugEnabled()) {
                    log.debug("Executing POST Request for URL " +
                              request.getURL());
                }
                PostRequest post = (PostRequest) request;

                code = http_session.s_post(basheader, post.getRequestBody(),
                                           post.getContentType(), post.getURL());
            }

        }
        // Wait until the method shows up in our hashtable
        /*
                 if (httpwaitForCompletion(DEFAULT_HTTP_TIMEOUT) == 1) {
            code = -1;
                 } else {
            code = 200;

                 }*/
        int count = 0;
        for (count = 0; count < 3; count++) {
            if (httpwaitForCompletion(DEFAULT_HTTP_TIMEOUT) == 1) {
                code = -1;
                waitfor = 0;
                //http_session.pThreadClose();

                if (http_session.Sconnect() == 7) {
                    if (count >= 2) {
                        break;
                    }
                } else {
                    if (count < 2) {
                        if (request instanceof GetRequest) {
                            System.out.println(count +
                                               " Executing GET Request for URL " +
                                               request.getURL());
                            http_session.s_get(basheader, request.getURL());
                        } else if (request instanceof PostRequest) {
                            System.out.println(count +
                                               " Executing POST Request for URL " +
                                               request.getURL());
                            PostRequest post = (PostRequest) request;

                            code = http_session.s_post(basheader,
                                    post.getRequestBody(),
                                    post.getContentType(), post.getURL());

                        }
                    } else {
                        code = -1;
                        break;
                    }

                }
            } else {
                code = 200;
                break;
            }

        }

        if (log.isDebugEnabled()) {
            log.debug("Waiting " + timeout + "ms for execute completion...");
        }

        return code;
    }

    /**
     * Execute a request. The client must be connected to the gateway.
     * @param request the request to execute
     * @param timeout timeout in milliseconds
     * @return the response
     * @throws SocketException if a timeout occurred
     * @throws IllegalStateException if the client is not connected
     */
    public Response execute(Request request, long timeout) throws
            SocketException,
            IllegalStateException {
        CWSPMethodManager mgr = null;
        CWSPHeaders headers = request.getWSPHeaders();
        synchronized (this) {
            if (session == null) {
                throw new IllegalStateException("Not yet connected");
            }

            if (headers.getHeader("Encoding-Version") == null) {
                headers.setHeader("Encoding-Version", "2.0");
            }

            if (headers.getHeader("Accept") == null) {
                headers.setHeader("Accept", "*/*");
                headers.addHeader("Accept", "application/vnd.wap.wmlc");
                headers.addHeader("Accept",
                                  "application/vnd.wap.multipart.mixed");
                headers.addHeader("Accept", "application/vnd.wap.wmlcscriptc");
                headers.addHeader("Accept",
                                  "application/vnd.wap.multipart.related");
                headers.addHeader("Accept", "application/octet-stream");
                headers.addHeader("Accept", "text/plain");
                headers.addHeader("Accept", "text/css");
                headers.addHeader("Accept", "image/bmp");
                headers.addHeader("Accept", "image/gif");
                headers.addHeader("Accept", "image/jpg");
                headers.addHeader("Accept", "image/png");
                headers.addHeader("Accept", "image/vnd.wap.wbmp");
                headers.addHeader("Accept", "application/smil");
                headers.addHeader("Accept", "application/vnd.wap.mms-message");
                headers.addHeader("Accept", "text/vnd.sun.j2me.app-descriptor");
                headers.addHeader("Accept", "application/java-archive");

                headers.setHeader("Profile", "URIx");
                headers.addHeader("Profile", "URIy");

            }

            String uh = headers.getHeader("User-Agent");
            if (uh == null) {

                headers.setHeader("User-Agent", AgentName);
            } else if ("".equals(uh)) {
                headers.setHeader("User-Agent", AgentName);
            }

            if (request instanceof GetRequest) {
                System.out.println("Executing GET Request for URL " +
                                   request.getURL());
                if (log.isDebugEnabled()) {
                    log.debug("Executing GET Request for URL " + request.getURL());
                }
                mgr = session.s_get(headers, request.getURL());
            } else if (request instanceof PostRequest) {
                System.out.println("Executing POST Request for URL " +
                                   request.getURL());
                if (log.isDebugEnabled()) {
                    log.debug("Executing POST Request for URL " +
                              request.getURL());
                }
                PostRequest post = (PostRequest) request;
                mgr = session.s_post(post.getWSPHeaders(), post.getRequestBody(),
                                     post.getContentType(), post.getURL());
            }
        }
        // Wait until the method shows up in our hashtable
        if (log.isDebugEnabled()) {
            log.debug("Waiting " + timeout + "ms for execute completion...");
        }
        int count = 0;
        Response response = null;
        for (count = 0; count < 3; count++) {
            response = null;
            response = (Response) waitForCompletion(mgr, timeout);
            if (response == null) {
                if (count < 2) {

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩av在线播放中文字幕| 视频一区欧美精品| 亚洲另类一区二区| 蜜桃精品视频在线观看| 91免费看`日韩一区二区| 在线播放欧美女士性生活| 中文字幕欧美国产| 奇米精品一区二区三区在线观看 | 日韩精品一区二区在线| 日本一区二区不卡视频| 久久激情综合网| 在线视频国产一区| 日韩一区二区三区免费看| 一区二区三区四区视频精品免费 | 日韩av中文字幕一区二区三区 | 亚洲欧洲综合另类| 国产原创一区二区三区| 欧美一区二区三区在线看| 亚洲免费资源在线播放| 成人黄色软件下载| 国产日韩欧美精品在线| 麻豆91精品视频| 91精品国产欧美一区二区 | 亚洲欧洲99久久| 久久不见久久见免费视频7| 欧美日韩高清在线播放| 亚洲黄色性网站| 不卡的av在线播放| 国产午夜精品理论片a级大结局| 免费看黄色91| 欧美福利一区二区| 亚洲与欧洲av电影| 91福利在线播放| 亚洲精品免费在线观看| 成人av电影观看| 久久精品欧美日韩| 国产成人一区在线| 欧美国产激情二区三区| 成人一区二区三区| 日本一区二区三区国色天香| 国产精选一区二区三区| 日韩限制级电影在线观看| 亚洲一区二区三区小说| 欧美日韩一区三区| 日本美女一区二区三区| 欧美一区二区三区视频免费播放| 午夜精品福利在线| 欧美一区二区三区免费观看视频| 久久99久久99| 国产三级久久久| 成人h动漫精品一区二区 | 久久久国产一区二区三区四区小说| 国产在线视频一区二区| 国产精品美女久久久久久2018| 99久久精品国产毛片| 亚洲国产精品影院| 欧美va天堂va视频va在线| 国产成人免费视频网站| 亚洲精品视频在线看| 欧美日韩久久一区二区| 极品少妇xxxx精品少妇| 中文字幕在线观看一区二区| 在线观看日韩一区| 韩国av一区二区三区四区| 亚洲欧洲日产国产综合网| 欧美日韩aaaaaa| 国产suv精品一区二区三区| 亚洲精品国产精品乱码不99| 日韩一区二区三区在线| 成人精品鲁一区一区二区| 亚洲精品日产精品乱码不卡| 日韩久久精品一区| 97久久精品人人做人人爽| 五月激情六月综合| 欧美国产1区2区| 4438成人网| 99视频一区二区三区| 麻豆精品视频在线观看视频| 亚洲视频香蕉人妖| 久久综合色综合88| 欧美日韩精品一区二区| 国产盗摄一区二区三区| 婷婷久久综合九色国产成人| 国产精品美女久久久久aⅴ | 亚洲色图20p| www激情久久| 欧美老肥妇做.爰bbww| 成人免费视频网站在线观看| 蜜乳av一区二区| 亚洲欧美日韩一区二区| 久久亚洲一区二区三区四区| 在线播放欧美女士性生活| 色偷偷久久人人79超碰人人澡| 国产一区二区成人久久免费影院| 亚洲成人tv网| 伊人性伊人情综合网| 中文字幕精品在线不卡| 精品国产一区二区在线观看| 欧美区在线观看| 在线欧美日韩国产| 99久久久国产精品免费蜜臀| 岛国一区二区在线观看| 久久er精品视频| 日韩国产一区二| 五月婷婷色综合| 亚洲国产精品久久人人爱蜜臀| 亚洲桃色在线一区| 专区另类欧美日韩| 国产精品九色蝌蚪自拍| 欧美国产视频在线| 亚洲国产精品黑人久久久| 久久久久久久综合| 久久久亚洲精品一区二区三区| 91视频com| 亚洲v中文字幕| 欧美国产一区二区在线观看| 在线观看日韩毛片| 国内成人免费视频| 日韩精品每日更新| 亚洲不卡av一区二区三区| 三级精品在线观看| 青娱乐精品视频| 免费成人美女在线观看| 看片的网站亚洲| 美脚の诱脚舐め脚责91 | 国产午夜亚洲精品午夜鲁丝片| 日韩欧美一区二区免费| 91精品国产手机| 精品国产乱码久久久久久牛牛| 日韩一级成人av| 久久婷婷国产综合国色天香| 国产亚洲成aⅴ人片在线观看| 久久精品夜色噜噜亚洲aⅴ| 久久久久久影视| 成人免费在线视频观看| 亚洲一区二区三区激情| 日本91福利区| 国产二区国产一区在线观看| 91免费观看视频| 欧美精品第一页| 欧美sm极限捆绑bd| 国产精品污www在线观看| 亚洲欧美一区二区视频| 午夜精品久久久久久久久久久 | 日韩精品中文字幕一区二区三区| 日韩一级片网站| 中文字幕av在线一区二区三区| 成人免费在线观看入口| 日本视频一区二区三区| 懂色av一区二区三区免费看| 欧美在线短视频| 久久丝袜美腿综合| 亚洲美女免费在线| 久久国产精品99精品国产| 91在线观看地址| 91精品国产aⅴ一区二区| 国产人成亚洲第一网站在线播放| 亚洲美女视频一区| 国产乱码精品一区二区三区av| 色偷偷成人一区二区三区91| 精品国产乱码久久久久久图片| 一区二区三区国产| 国产精品一二三四区| 欧美日韩国产高清一区二区三区| 国产欧美一区二区在线观看| 日日欢夜夜爽一区| 91麻豆高清视频| 久久人人97超碰com| 丝袜诱惑亚洲看片| 91香蕉视频黄| 国产欧美一区二区三区在线老狼| 亚洲444eee在线观看| 99久久久免费精品国产一区二区| 精品人在线二区三区| 亚洲国产三级在线| 99这里只有久久精品视频| 日韩午夜在线观看视频| 亚洲曰韩产成在线| 色诱视频网站一区| 国产精品区一区二区三区| 捆绑调教美女网站视频一区| 欧洲国产伦久久久久久久| 国产精品免费丝袜| 国产成人自拍网| 久久久久久久久久电影| 麻豆精品在线看| 91 com成人网| 亚洲成人免费av| 欧美午夜免费电影| 一区二区三区电影在线播| 成人av电影在线网| 国产精品无码永久免费888| 国产999精品久久久久久绿帽| 精品国产乱码久久久久久免费 | 成人aa视频在线观看| 精品第一国产综合精品aⅴ| 蜜臀av性久久久久蜜臀aⅴ流畅| 91成人免费网站| 一区二区三区四区不卡在线 | www.欧美日韩|