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

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

?? hsocket.java~266~

?? jwap 協議 udp 可以用于手機通訊
?? JAVA~266~
?? 第 1 頁 / 共 2 頁
字號:
package net.sourceforge.jwap.http;

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

import net.sourceforge.jwap.util.*;
import net.sourceforge.jwap.wtp.markflg;

public class HSocket implements Runnable {

    static Logger logger = Logger.getLogger(HSocket.class);
    public Socket TcpSocket = null;
    public DataOutputStream Tcpoutput = null;
    public DataInputStream Tcpinput = null;
    protected URL target;
    private int responseCode = -1;
    private String responseMessage = "";
    private String serverVersion = "";
    protected ByteArrayInputStream byteStream;
    public String baseheader;
    private Properties header = new Properties();
    private Thread runner = null;
    public String geturl = "";
    public int icount = 1;
    public int get_post = 0;
    protected byte[] payload;
    private String contentType;

    /**
     * the upper Layer, modelling the session, WSP
     */
    private HttpUpperLayer upperLayer;

// remote port and address
    private int toPort = 80;
    private InetAddress toAddress;


    public HSocket() {
    }

    public HSocket(InetAddress mtoAddress, int mtoPort,
                   InetAddress localAddress,
                   int localPort, HttpUpperLayer m_upperLayer) {
        try {
            String str = mtoAddress.getHostAddress();
            toAddress = mtoAddress;
            toPort = mtoPort;
            TcpSocket = new Socket(mtoAddress.getHostAddress(), mtoPort);
            //TcpSocket = new Socket();
            Tcpoutput = new DataOutputStream(TcpSocket.getOutputStream());
            Tcpinput = new DataInputStream(TcpSocket.getInputStream());
            this.upperLayer = m_upperLayer;

        } catch (Exception ex) {
            TcpSocket = null;
        }

    }

    public void streamcreat() {
        if (TcpSocket == null) {
            try {
                TcpSocket = new Socket(toAddress.getHostAddress(), toPort);
            } catch (UnknownHostException ex3) {
            } catch (IOException ex3) {
            }
        }
        if (Tcpoutput != null) {
            try {
                Tcpoutput.close();
            } catch (IOException ex1) {
            }
            Tcpoutput = null;
        }
        if (Tcpinput != null) {
            try {
                Tcpinput.close();
            } catch (IOException ex2) {
            }
            Tcpinput = null;
        }

        try {
            Tcpoutput = new DataOutputStream(TcpSocket.getOutputStream());

            Tcpinput = new DataInputStream(TcpSocket.getInputStream());
        } catch (IOException ex) {
            System.out.println(ex.getMessage());
        }
    }

    public static void main(String[] args) {
        HSocket hsocket = new HSocket();
    }

    /**
     * Sconnect
     *
     * @param aLong long
     */
    public int Sconnect(InetAddress toAddress, int toPort, long timeout) {
        int ret = 8;
        return ret;
    }

    public int Sconnect() {
        int ret = 0;
        TcpSocket = null;
        try {
            TcpSocket = new Socket(toAddress.getHostAddress(), toPort);
            ret = 1;
        } catch (UnknownHostException ex) {
        } catch (IOException ex) {
        }
        //TcpSocket = new Socket();
        try {
            Tcpoutput = new DataOutputStream(TcpSocket.getOutputStream());
        } catch (IOException ex1) {
        }
        try {
            Tcpinput = new DataInputStream(TcpSocket.getInputStream());
        } catch (IOException ex2) {
        }

        return ret;
    }


    /**
     * SetSocketTimeout
     *
     * @param timeout long
     */
    public void SetSocketTimeout(int timeout) {
        try {
            TcpSocket.setSoTimeout(timeout);
        } catch (SocketException ex) {
        }
    }

    protected String getURLFormat(URL target) {
        String spec = "http://" + target.getHost();
        if (target.getPort() != -1) {
            spec += ":" + target.getPort();
        }
        return spec += target.getFile();
    }

    /* 向Web服務器傳送數據 */
    protected void sendMessage(String data) throws IOException {
        Tcpoutput.write(data.getBytes(), 0, data.length());
        Tcpoutput.flush();
    }

    /* 向Web服務器傳送數據 */
    protected void sendData(String data) throws IOException {
        Tcpoutput.write(data.getBytes(), 0, data.length());
        Tcpoutput.flush();
        int len = payload.length;
        // int count=(len/1024)+1;
        byte sendbuf[] = new byte[1024];
        int count = 0;
        int copylen = 0;
        for (int i = 0; i < len; ) {
            if ((len - i) < 1023) {
                copylen = len - i;
            } else {
                copylen = 1024;
            }
            System.arraycopy(payload, i, sendbuf, 0, copylen);
            i = i + 1024;
            Tcpoutput.write(sendbuf, 0, sendbuf.length);
            count++;
            System.out.println(count + " 發送" + copylen + " 個字節");
            Tcpoutput.flush();
        }
        //Tcpoutput.write(payload, 0, payload.length);
        String endstr = "\r\n";
        Tcpoutput.write(endstr.getBytes(), 0, endstr.length());
        Tcpoutput.flush();
    }

    protected void receiveSendBack() {
        byte data[] = new byte[1024];
        int count = 0;
        int word = -1;
        int totlelen = 0;

// 解析第一行Tcpinput
        System.out.println("請稍后,等待回應......");

        try {
            while ((word = Tcpinput.read()) != -1) {
                if (word == '\r' || word == '\n') {
                    word = Tcpinput.read();
                    if (word == '\n') {
                        word = Tcpinput.read();
                    }
                    break;
                }
                if (count == data.length) {
                    data = addCapacity(data);
                }
                data[count++] = (byte) word;
            }
            String message = new String(data, 0, count);
            logger.error(message);
            int mark = message.indexOf(32);
            serverVersion = message.substring(0, mark);
            while (mark < message.length() && message.charAt(mark + 1) == 32) {
                mark++;
            }
            responseCode = Integer.parseInt(message.substring(mark + 1,
                    mark += 4));
            responseMessage = message.substring(mark, message.length()).trim();
            /* if(responseCode==200)
             {
                 upperLayer.tr_download(responseCode);
             }*/
            // 應答狀態碼和處理請讀者添加
            switch (responseCode) {
            case 400:
                System.out.println("錯誤請求");
                throw new IOException("錯誤請求");
            case 404:
                System.out.println(getURLFormat(target));
                throw new FileNotFoundException(getURLFormat(target));
            case 503:
                System.out.println("服務器不可用");
                throw new IOException("服務器不可用");
            }

            if (word == -1) {
                System.out.println("信息接收異常終止");
                throw new ProtocolException("信息接收異常終止");
            }

            int symbol = -1;
            count = 0;
            // 解析元信息
            while (word != '\r' && word != '\n' && word > -1) {
                if (word == '\t') {
                    word = 32;
                }
                if (count == data.length) {
                    data = addCapacity(data);
                }
                data[count++] = (byte) word;
                parseLine: {
                    while ((symbol = Tcpinput.read()) > -1) {
                        switch (symbol) {
                        case '\t':
                            symbol = 32;
                            break;
                        case '\r':
                        case '\n':
                            word = Tcpinput.read();
                            if (symbol == '\r' && word == '\n') {
                                word = Tcpinput.read();
                                if (word == '\r') {
                                    word = Tcpinput.read();
                                }
                            }
                            if (word == '\r' || word == '\n' || word > 32) {
                                break parseLine;
                            }
                            symbol = 32;
                            break;
                        }
                        if (count == data.length) {
                            data = addCapacity(data);
                        }
                        data[count++] = (byte) symbol;
                    }
                    word = -1;
                }
                message = new String(data, 0, count);
                logger.error(message);
                mark = message.indexOf(':');
                String key = null;
                if (mark > 0) {
                    key = message.substring(0, mark);
                }
                mark++;
                while (mark < message.length() && message.charAt(mark) <= 32) {
                    mark++;
                }
                String value = message.substring(mark, message.length());
                String str = key.toLowerCase();
                if (str.equals("content-length")) {
                    totlelen = Integer.parseInt(value.trim());
                }
                header.put(key, value);
                count = 0;
            }

            // 獲得正文數據
            byte databuf[] = new byte[1024];
            while (((word = Tcpinput.read()) != -1)) {
                if (count == data.length) {
                    data = addCapacity(data);
                }

                data[count++] = (byte) word;
                if (count >= totlelen) {
                    break;
                }

                //markflg.ReceiveBag();
                //data = temp;//addCapacitybuf(data, databuf);
            }

//=======================================================================
            /* if (word > 0) {
                 if(icount==1)
                 {
                   System.arraycopy(databuf, 0, data, 0, word);
                    System.out.println(icount + " 接收到 1024 字節");
                   icount++;
                 }
                   else
                   {
                       int len = data.length;
                       byte temp[] = new byte[data.length + word];

                       System.out.println(icount + " 接收到 1024 字節");
                       icount++;
                       System.arraycopy(data, 0, temp, 0, data.length);
                       System.arraycopy(databuf, 0, temp, data.length, word);
                       data = temp;

                   }
                 markflg.ReceiveBag();

                 //data = temp;//addCapacitybuf(data, databuf);
                 count=data.length;
                  if(count>=totlelen)
                  {
                      break;
                  }
             }
                            }*/
            //==================================================================================

            if (count > 0) {
                upperLayer.tr_download(responseCode);

                byteStream = new ByteArrayInputStream(data, 0, count);
            }
            // data = null;
        } catch (IOException ex) {
            responseCode = -1;
            String str = "接收回應失敗";
            byteStream = new ByteArrayInputStream(str.getBytes());
            System.out.println(ex.getMessage());
        }
        //upperLayer.tr_downok(outdate);
        try {
            if (responseCode == -1) {
                int len = data.length;
                if (len > 0) {
                    byteStream = new ByteArrayInputStream(data, 0, len);
                } else {
                    responseCode = -1;
                    String str = "接收回應失敗";
                    byteStream = new ByteArrayInputStream(str.getBytes());
                }
            }
            closeServer();
        } catch (Exception ex1) {
            responseCode = -1;
        }

        finally {
            data = null;
            System.out.println(responseCode);
            System.out.println(responseMessage);
            //System.out.println(responseCode);

        }
    }


    /* 接收來自Web服務器的數據 */
    protected void receiveMessage() {
        byte data[] = new byte[1024];
        int count = 0;
        int word = -1;
        int totlelen = 0;

// 解析第一行Tcpinput
        System.out.println("請稍后,正在下載中......");

        try {
            while ((word = Tcpinput.read()) != -1) {
                if (word == '\r' || word == '\n') {
                    word = Tcpinput.read();
                    if (word == '\n') {
                        word = Tcpinput.read();
                    }
                    break;
                }
                if (count == data.length) {
                    data = addCapacity(data);
                }
                data[count++] = (byte) word;
            }
            String message = new String(data, 0, count);
            logger.error(message);
            int mark = message.indexOf(32);
            serverVersion = message.substring(0, mark);
            while (mark < message.length() && message.charAt(mark + 1) == 32) {
                mark++;
            }
            responseCode = Integer.parseInt(message.substring(mark + 1,
                    mark += 4));
            responseMessage = message.substring(mark, message.length()).trim();

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
极品少妇一区二区三区精品视频| 欧美亚洲禁片免费| 亚洲欧美一区二区在线观看| proumb性欧美在线观看| 中文字幕人成不卡一区| 一本大道久久a久久综合婷婷| 一区二区理论电影在线观看| 在线不卡中文字幕| 久久国产欧美日韩精品| 国产亚洲欧美日韩日本| 99精品欧美一区二区三区小说| 亚洲激情在线激情| 7777精品伊人久久久大香线蕉经典版下载 | 亚洲摸摸操操av| 欧美视频第二页| 美女www一区二区| 欧美国产亚洲另类动漫| 色一情一伦一子一伦一区| 亚洲gay无套男同| 精品久久久三级丝袜| 成人av电影在线网| 亚洲最色的网站| 欧美一区中文字幕| 国产成人综合自拍| 一区二区国产视频| 日韩精品一区二| 成人黄色电影在线 | 日韩精品最新网址| 粉嫩一区二区三区性色av| 一区二区三区欧美亚洲| 欧美肥妇毛茸茸| 岛国av在线一区| 亚洲午夜在线电影| 欧美精品一区男女天堂| 色婷婷av久久久久久久| 久久国产人妖系列| 亚洲视频中文字幕| 欧美一级欧美一级在线播放| 东方aⅴ免费观看久久av| 亚洲国产精品一区二区尤物区| 久久午夜免费电影| 色先锋资源久久综合| 久久成人免费网站| 亚洲女性喷水在线观看一区| 日韩欧美专区在线| 色婷婷久久久亚洲一区二区三区| 麻豆91免费看| 国产精品第五页| 欧美成人精品二区三区99精品| 94-欧美-setu| 精品一区二区三区在线视频| 亚洲一区二区欧美日韩| 久久精品欧美一区二区三区麻豆 | 久久日韩精品一区二区五区| 91丝袜美腿高跟国产极品老师| 蜜桃av一区二区| 一区二区三区成人在线视频| 国产香蕉久久精品综合网| 欧美日韩视频在线一区二区 | 99re热这里只有精品免费视频| 丝袜美腿亚洲一区| 国产精品午夜电影| 日韩写真欧美这视频| 欧美性受xxxx| 97精品国产露脸对白| 国产美女视频一区| 日韩电影免费在线观看网站| 亚洲激情成人在线| 欧美激情一区二区| 欧美va亚洲va在线观看蝴蝶网| 欧美性大战久久久久久久蜜臀| 不卡av电影在线播放| 国产永久精品大片wwwapp| 日本不卡一二三| 亚洲一区电影777| 国产精品成人免费精品自在线观看| 精品国产乱码久久久久久蜜臀 | 久久精工是国产品牌吗| 亚洲激情图片一区| 精品国产3级a| 97精品国产露脸对白| 成人午夜视频在线| 美女国产一区二区| 一区二区三区波多野结衣在线观看 | 色呦呦一区二区三区| 国产精品一区二区三区99| 日韩影院在线观看| 国产精品麻豆网站| 国产日韩精品一区二区三区 | 欧美电视剧在线观看完整版| www.亚洲免费av| 热久久国产精品| 视频一区视频二区中文| 一区二区三区中文字幕| 亚洲国产精品精华液2区45| 日韩视频免费观看高清完整版在线观看 | 1区2区3区精品视频| 欧美精品一区二区三区蜜臀| 欧美亚洲日本一区| 精品视频在线看| 99精品视频一区| 成+人+亚洲+综合天堂| 国产原创一区二区三区| 美女视频免费一区| 日韩av一区二区三区四区| 亚洲视频免费在线| 国产精品五月天| 亚洲国产成人午夜在线一区| 久久久综合网站| 日韩欧美国产综合| 91精品国产色综合久久不卡电影| 欧美亚洲一区三区| 色婷婷久久久综合中文字幕| 91在线观看下载| eeuss鲁片一区二区三区 | 国产mv日韩mv欧美| 国产成人av电影| 国产成人免费视频一区| 日本v片在线高清不卡在线观看| 老司机精品视频一区二区三区| 日本最新不卡在线| 日韩 欧美一区二区三区| 日韩黄色片在线观看| 天天操天天综合网| 爽好多水快深点欧美视频| 一区二区三区精品| 日韩国产高清影视| 奇米亚洲午夜久久精品| 琪琪久久久久日韩精品| 免费成人结看片| 精品一区二区三区av| 国产美女精品人人做人人爽 | 国产精品一区一区| 麻豆精品一区二区三区| 国产一区三区三区| 国产精品综合在线视频| 国产ts人妖一区二区| www.综合网.com| 91亚洲永久精品| 在线视频国产一区| 欧美精品在欧美一区二区少妇 | av电影在线观看不卡| 91麻豆123| 欧美日韩国产系列| 在线播放日韩导航| 日韩精品影音先锋| 国产精品网站一区| 亚洲丝袜自拍清纯另类| 一二三区精品视频| 日韩精品电影在线| 国产在线精品国自产拍免费| 成人av资源网站| 欧美视频中文字幕| 日韩一级黄色片| 国产性色一区二区| 亚洲欧美日韩国产综合在线| 亚洲国产sm捆绑调教视频| 日韩电影免费在线看| 国产99精品国产| 欧美亚洲国产怡红院影院| 欧美一级视频精品观看| 亚洲国产精品成人综合| 亚洲乱码国产乱码精品精98午夜| 亚洲国产欧美一区二区三区丁香婷| 亚洲成精国产精品女| 国产精品99久久久久久有的能看 | 久久久久国产成人精品亚洲午夜| 国产精品色在线观看| 一区二区三区国产豹纹内裤在线| 轻轻草成人在线| 国产sm精品调教视频网站| 在线免费精品视频| 精品国产一区二区精华| 中文字幕一区免费在线观看| 亚洲国产一区二区三区青草影视| 蜜桃精品视频在线观看| 高清视频一区二区| 欧美三级在线看| 欧美三片在线视频观看| 国产精品无人区| 日韩黄色免费网站| 成人国产在线观看| 欧美日韩aaaaaa| 中文字幕精品—区二区四季| 一区二区在线免费| 久久99精品久久久久婷婷| 99精品热视频| 精品日产卡一卡二卡麻豆| 亚洲视频在线观看一区| 亚洲国产精品久久艾草纯爱| 风间由美一区二区av101| 欧美精品v日韩精品v韩国精品v| 国产婷婷一区二区| 亚洲国产成人av网| 大美女一区二区三区| 欧美日韩你懂的| 亚洲美女免费视频| 激情欧美一区二区| 在线亚洲一区观看| 国产性色一区二区|