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

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

?? wapptr.java~354~

?? jwap 協議 udp 可以用于手機通訊
?? JAVA~354~
?? 第 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) {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
悠悠色在线精品| 亚洲国产色一区| 精品在线视频一区| 欧美日韩国产不卡| 亚洲精品成人精品456| 国产乱码精品1区2区3区| 91精品国产色综合久久不卡蜜臀| 亚洲精品欧美专区| 欧洲av在线精品| 亚洲成人动漫一区| 日韩欧美中文字幕公布| 久久99精品网久久| 欧美国产精品v| 成人av在线播放网址| 一区二区三区日本| 91麻豆精品国产自产在线观看一区| 日韩国产精品91| 2023国产精品| 成人精品小蝌蚪| 亚洲国产精品久久人人爱| 这里是久久伊人| 国产成人综合亚洲网站| 亚洲欧洲制服丝袜| 日韩午夜在线播放| 国v精品久久久网| 午夜电影网一区| 欧美精品一区二区三区四区 | 午夜亚洲福利老司机| 精品欧美一区二区三区精品久久| 蜜桃av噜噜一区| 国产精品精品国产色婷婷| 欧美日韩成人一区| 成人aaaa免费全部观看| 日本不卡一二三区黄网| 国产精品视频第一区| 日韩欧美国产午夜精品| 色悠久久久久综合欧美99| 蓝色福利精品导航| 亚洲国产综合在线| 中文av字幕一区| 久久精品欧美一区二区三区不卡| 欧美视频一区二区在线观看| 成人美女视频在线观看| 另类小说综合欧美亚洲| 亚洲va在线va天堂| 一区二区三区欧美亚洲| 国产精品久久久久四虎| 欧美精品一区二区在线观看| 欧美一区二区三区视频| 日本丶国产丶欧美色综合| 色综合天天狠狠| 91黄色免费看| 欧美年轻男男videosbes| 欧美三片在线视频观看| 精品视频1区2区| 欧美日本一区二区三区四区| 欧美人牲a欧美精品| 在线观看三级视频欧美| 欧美日韩一卡二卡| 91精品国产品国语在线不卡| 日韩欧美国产麻豆| 久久久久久久一区| 国产精品国模大尺度视频| 久久九九国产精品| 亚洲欧美国产77777| 偷拍一区二区三区四区| 黄网站免费久久| 成人免费观看av| 欧美日韩免费在线视频| 国产成人av电影| 99久久精品一区二区| 欧美三级资源在线| 欧美激情在线一区二区| 亚洲自拍与偷拍| 国产乱子伦视频一区二区三区 | 久久婷婷综合激情| 亚洲视频网在线直播| 日本麻豆一区二区三区视频| 国产成人在线电影| 欧美一区二区三区免费在线看 | 欧美日韩高清在线播放| 日本一区二区不卡视频| 日韩精品午夜视频| 99re成人在线| 国产午夜久久久久| 午夜影院久久久| 91久久精品网| 国产精品久久久久天堂| 国模娜娜一区二区三区| 欧美一区二区免费| 一区二区三区高清不卡| a4yy欧美一区二区三区| 久久久久久久电影| 蜜桃视频一区二区三区在线观看| 欧美视频你懂的| 亚洲欧美日韩国产另类专区| 成人黄色综合网站| 久久久精品国产免费观看同学| 欧美aaa在线| 欧美一级片在线看| 日本大胆欧美人术艺术动态| 欧美精品久久久久久久久老牛影院| 国产人久久人人人人爽| 国产在线精品一区二区三区不卡| 日韩欧美电影在线| 精品中文字幕一区二区小辣椒| 5月丁香婷婷综合| 日韩专区中文字幕一区二区| 在线播放国产精品二区一二区四区 | 亚洲va欧美va国产va天堂影院| 欧美自拍偷拍一区| 日本亚洲三级在线| 久久综合久久99| 成人性生交大片免费看在线播放| 国产精品久久国产精麻豆99网站| 成人激情免费网站| 午夜av区久久| 久久色视频免费观看| 91免费观看视频| 日本不卡一二三区黄网| 中文字幕的久久| 欧美色涩在线第一页| 国模一区二区三区白浆| 夜夜爽夜夜爽精品视频| 日韩美女在线视频| 精品视频一区二区三区免费| 国产精品一区专区| 日韩精品电影在线观看| 国产精品久久一级| 精品国产一区久久| 欧美三级在线播放| 99久久精品情趣| 国产成人在线看| 久久超级碰视频| 午夜精品一区二区三区三上悠亚| 国产日韩欧美精品在线| 欧美肥妇毛茸茸| 在线日韩一区二区| jlzzjlzz亚洲女人18| 国产精品亚洲а∨天堂免在线| 另类调教123区 | 国产一区二区电影| 日韩电影在线看| 日韩精品成人一区二区三区| 亚洲在线中文字幕| 亚洲一区二区三区不卡国产欧美| 综合欧美一区二区三区| 中文字幕第一区二区| 国产精品第13页| 亚洲欧美另类小说| 樱桃视频在线观看一区| 亚洲永久精品大片| 亚洲国产va精品久久久不卡综合| 亚洲中国最大av网站| 亚洲成av人**亚洲成av**| 日日噜噜夜夜狠狠视频欧美人| 日本vs亚洲vs韩国一区三区二区 | 国产精品国产三级国产aⅴ中文| 日韩精品中午字幕| 久久综合给合久久狠狠狠97色69| 久久人人爽爽爽人久久久| 精品国产在天天线2019| 国产精品三级电影| 一区二区三区国产精品| 日韩国产在线观看| 国产成人免费在线观看不卡| av一区二区三区| 欧美日韩视频在线一区二区| 91精品国产综合久久久蜜臀图片| 欧美大片在线观看| 国产精品久久毛片| 亚洲成人在线网站| 国产传媒一区在线| 欧美网站一区二区| 久久久久高清精品| 亚洲bt欧美bt精品| eeuss影院一区二区三区| 欧美裸体一区二区三区| 91免费版在线| 精品成人一区二区三区| 亚洲小少妇裸体bbw| 成人理论电影网| 2024国产精品| 日韩av高清在线观看| 日本高清免费不卡视频| 欧美高清一级片在线观看| 美女一区二区久久| 欧美丰满高潮xxxx喷水动漫| 亚洲乱码国产乱码精品精98午夜 | 免费观看日韩电影| 欧美中文字幕一区| 亚洲欧美日韩国产一区二区三区| 国产精品77777| 久久亚洲免费视频| 久久99国产乱子伦精品免费| 欧美日韩美少妇 | 国产精品免费视频观看| 国产高清不卡一区| 久久精品夜色噜噜亚洲a∨| 国产一区二区精品久久|