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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? wapptr.java~349~

?? jwap 協議 udp 可以用于手機通訊
?? JAVA~349~
?? 第 1 頁 / 共 5 頁
字號:
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) {
                    if (request instanceof GetRequest) {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91成人免费在线视频| 国产一区二三区| 91视频www| 亚洲女人的天堂| 欧美性受极品xxxx喷水| 日韩国产精品91| 久久一日本道色综合| 国产一区二区三区精品视频| 久久久精品tv| 91在线观看下载| 韩国欧美国产一区| 精品国产乱码久久久久久久久 | 蜜臀av性久久久久蜜臀aⅴ流畅| 欧美一级黄色大片| 成人免费福利片| 亚洲精品国产无套在线观| 9191久久久久久久久久久| 精品一区二区精品| 亚洲区小说区图片区qvod| 欧美日韩高清在线播放| 国产综合色精品一区二区三区| 国产欧美精品区一区二区三区| 91视频在线观看免费| 七七婷婷婷婷精品国产| 久久精品视频一区| 欧美视频在线观看一区二区| 看片网站欧美日韩| 亚洲视频免费在线| 欧美一区二区视频在线观看| 国产 欧美在线| 亚洲一卡二卡三卡四卡无卡久久| 日韩区在线观看| 99久久国产综合精品色伊| 日本午夜精品视频在线观看 | 欧美一区二区播放| 不卡一区在线观看| 美女性感视频久久| 中文字幕五月欧美| 日韩一本二本av| 色综合久久88色综合天天免费| 日本在线不卡视频| 亚洲精品视频在线看| 26uuu久久综合| 欧美午夜免费电影| 成人一区二区三区中文字幕| 偷偷要91色婷婷| 亚洲婷婷在线视频| 2017欧美狠狠色| 欧美肥胖老妇做爰| 日本精品裸体写真集在线观看| 国产在线视频不卡二| 亚洲成av人片在线观看无码| 中文字幕的久久| 精品国产乱码久久久久久夜甘婷婷 | 精品久久久久久久久久久久久久久| 色综合久久66| 成人av电影免费在线播放| 免费成人在线影院| 午夜精品久久久久久| 亚洲视频精选在线| 国产精品美女久久久久久2018| 日韩精品一区二区三区在线| 欧美日韩久久一区二区| 色哟哟在线观看一区二区三区| 国产 欧美在线| 高清久久久久久| 国产一区二三区好的| 狠狠狠色丁香婷婷综合久久五月| 亚洲资源中文字幕| 亚洲一区二区三区四区五区黄| 国产精品嫩草99a| 久久久久久久一区| 久久久不卡影院| 国产免费久久精品| 国产视频一区在线播放| 久久青草国产手机看片福利盒子| 欧美成人a∨高清免费观看| 欧美一区二区三区电影| 欧美精品久久99久久在免费线 | 日本精品一级二级| 91黄视频在线观看| 91国偷自产一区二区三区成为亚洲经典 | 国产亚洲一区二区三区四区| 久久久久国产精品麻豆| 久久精品这里都是精品| 欧美国产成人精品| 亚洲女爱视频在线| 一二三区精品视频| 天天操天天综合网| 麻豆视频一区二区| 久久99精品久久久久久动态图| 韩日欧美一区二区三区| 国产成人免费高清| 97精品国产露脸对白| 色综合天天综合色综合av| 欧美在线免费播放| 欧美一区日本一区韩国一区| 欧美成人r级一区二区三区| 2021国产精品久久精品| 中文字幕一区二区视频| 一区二区三区四区视频精品免费 | 日本在线不卡视频| 国产传媒欧美日韩成人| 99久久婷婷国产综合精品电影| 91视频一区二区三区| 欧美一级淫片007| 中文字幕av一区二区三区| 亚洲欧美另类在线| 蜜臀av性久久久久蜜臀av麻豆| 国产精品自在欧美一区| 色综合天天做天天爱| 91精品国产一区二区三区香蕉| 久久久亚洲欧洲日产国码αv| 中文字幕一区免费在线观看| 日韩在线卡一卡二| 成人免费av资源| 欧美日韩成人在线一区| 欧美激情在线看| 天天亚洲美女在线视频| 丁香另类激情小说| 337p亚洲精品色噜噜狠狠| 国产精品麻豆一区二区| 婷婷一区二区三区| 成人av影视在线观看| 91精品国产入口在线| 国产精品看片你懂得| 裸体在线国模精品偷拍| 欧美在线观看视频一区二区三区| 精品成人佐山爱一区二区| 一区二区三区精品视频在线| 韩国av一区二区| 欧美久久一二区| 成人欧美一区二区三区| 国内不卡的二区三区中文字幕| 色婷婷久久久亚洲一区二区三区| 精品国产sm最大网站免费看| 亚洲永久精品大片| 99久久免费精品高清特色大片| 51精品秘密在线观看| 亚洲欧美一区二区三区国产精品| 激情国产一区二区| 91麻豆精品国产| 亚洲午夜一区二区三区| 成人高清av在线| 久久青草国产手机看片福利盒子| 天使萌一区二区三区免费观看| 北条麻妃国产九九精品视频| 26uuu欧美| 精品一区二区免费在线观看| 精品视频一区二区不卡| 亚洲免费在线视频一区 二区| 国产91高潮流白浆在线麻豆| 精品日韩成人av| 免费欧美高清视频| 欧美精品 日韩| 亚洲图片欧美一区| 欧美少妇一区二区| 亚洲精品中文字幕乱码三区| 99re热视频这里只精品| 中文字幕免费观看一区| 国产99一区视频免费| 国产亚洲1区2区3区| 韩国一区二区三区| 精品盗摄一区二区三区| 国精产品一区一区三区mba桃花 | 风间由美一区二区三区在线观看| 2014亚洲片线观看视频免费| 久久电影国产免费久久电影| 日韩视频中午一区| 精品在线免费观看| 精品久久久久久综合日本欧美| 久久66热偷产精品| 久久综合成人精品亚洲另类欧美 | 成人动漫中文字幕| 中文成人av在线| 99热这里都是精品| 亚洲欧洲av在线| 99久久精品免费看国产免费软件| 中文字幕日韩av资源站| 色狠狠桃花综合| 午夜av区久久| 国产校园另类小说区| 成人免费不卡视频| 亚洲免费看黄网站| 欧美日韩久久久久久| 日韩电影在线免费观看| 精品少妇一区二区三区免费观看| 精品一区二区三区久久| 国产精品视频一二三| 91啪亚洲精品| 婷婷久久综合九色国产成人| 日韩欧美在线影院| 国产69精品久久久久毛片| 亚洲欧美中日韩| 欧美亚洲综合另类| 理论电影国产精品| 国产精品三级久久久久三级| 在线精品视频免费观看| 日本麻豆一区二区三区视频| 国产三级精品三级|