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

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

?? hsocket.java~263~

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

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品日韩成人| 成人免费黄色在线| 一区二区三区蜜桃| 国产精品久久久久久久久免费丝袜| 日韩一区二区三区精品视频| 欧美亚洲图片小说| 国产精品福利一区| 欧美日韩精品一区二区三区四区| 不卡一区二区在线| 国产成人99久久亚洲综合精品| 国产精品影视网| 国产精品综合视频| 国产成人亚洲精品青草天美| 成人性生交大片免费看在线播放 | 欧美福利一区二区| 欧美日韩国产欧美日美国产精品| proumb性欧美在线观看| 成人v精品蜜桃久久一区| 91小视频免费看| 欧美午夜片在线看| 欧美一区二区国产| 久久综合网色—综合色88| 国产亚洲欧美色| 综合自拍亚洲综合图不卡区| 夜夜嗨av一区二区三区四季av| 午夜a成v人精品| 激情六月婷婷综合| 91在线视频18| 日韩午夜激情电影| 国产精品免费视频网站| 亚洲一区在线观看免费| 免费不卡在线观看| 丁香激情综合国产| 在线不卡欧美精品一区二区三区| 日韩一区二区免费高清| 国产精品久久久久影视| 亚洲电影欧美电影有声小说| 国产乱一区二区| 欧美丝袜丝交足nylons图片| 欧美videofree性高清杂交| 成人免费视频在线观看| 五月天久久比比资源色| 粉嫩一区二区三区性色av| 欧美影视一区在线| 久久人人97超碰com| 亚洲国产精品一区二区尤物区| 麻豆免费看一区二区三区| 91香蕉国产在线观看软件| 日韩精品一区二区三区在线播放| 国产精品天干天干在观线| 日本中文在线一区| 99久久777色| 亚洲精品在线免费播放| 亚洲一区二区三区三| 国产成都精品91一区二区三| 欧美日韩国产中文| 亚洲人成网站在线| 国产一区二区三区黄视频| 欧美日韩高清一区二区三区| 亚洲精品视频免费观看| 国产伦理精品不卡| 日韩欧美综合在线| 亚洲国产精品自拍| 在线观看三级视频欧美| 欧美韩日一区二区三区| 美美哒免费高清在线观看视频一区二区| 91小视频免费观看| 亚洲天堂中文字幕| www.成人网.com| 久久青草国产手机看片福利盒子 | 成人午夜免费电影| 欧美电影精品一区二区| 日韩在线播放一区二区| 欧美亚洲精品一区| 亚洲精品菠萝久久久久久久| 91一区二区三区在线观看| 国产日韩欧美激情| 国产高清精品网站| 2023国产精品| 国产精品亚洲一区二区三区在线| 精品精品国产高清一毛片一天堂| 亚洲成va人在线观看| 欧美日韩综合在线| 亚洲影院免费观看| 欧美色电影在线| 日韩在线卡一卡二| 欧美成va人片在线观看| 国产自产v一区二区三区c| 久久九九国产精品| 成人av资源站| 亚洲视频免费在线| 欧美中文字幕一区| 亚洲一区二区三区中文字幕| 911精品国产一区二区在线| 日韩主播视频在线| 精品国产一区a| 成人午夜看片网址| 亚洲一区二区三区影院| 日韩一二三四区| 国内精品在线播放| 亚洲欧美另类久久久精品 | 日韩影视精彩在线| 欧美成人女星排行榜| 国产剧情一区二区三区| 国产精品女主播在线观看| 在线观看欧美精品| 七七婷婷婷婷精品国产| 国产精品乱子久久久久| 欧美性猛片xxxx免费看久爱| 日韩不卡一二三区| 国产亚洲精久久久久久| 91视频国产观看| 美女国产一区二区三区| 综合久久久久久| 日韩欧美高清dvd碟片| 成人h动漫精品一区二| 天堂影院一区二区| 国产精品毛片高清在线完整版| 欧美亚洲综合在线| 国产成人精品亚洲午夜麻豆| 亚洲大片在线观看| 国产日本一区二区| 91精品国产色综合久久不卡蜜臀| 国产99久久精品| 看电影不卡的网站| 一区在线中文字幕| 日韩精品一区国产麻豆| 欧美日韩一区二区三区免费看| 风流少妇一区二区| 另类小说视频一区二区| 夜夜嗨av一区二区三区中文字幕 | 日韩欧美美女一区二区三区| 91免费视频大全| 国产精品白丝av| 久久精品理论片| 亚洲一级不卡视频| 亚洲三级免费观看| 久久久精品2019中文字幕之3| 91精品国产乱| 欧美日韩美少妇| 欧美这里有精品| 日本二三区不卡| 91蝌蚪porny成人天涯| 成人精品国产免费网站| 国产福利精品一区| 久久99精品国产麻豆不卡| 亚洲成va人在线观看| 亚洲免费av观看| 国产欧美日韩亚州综合 | 国产精品久久久久久久久免费丝袜 | 久久久久久久网| 欧美日免费三级在线| 色综合天天综合在线视频| 老司机精品视频在线| 亚洲黄色在线视频| 国产三级精品三级| 欧美日韩在线播放三区四区| 欧美在线制服丝袜| 91亚洲午夜精品久久久久久| 国产精品一区二区久激情瑜伽| 国产精品久久久久久久久果冻传媒| 精品欧美乱码久久久久久1区2区| 欧美日韩精品一区二区| 欧美喷潮久久久xxxxx| 欧美高清www午色夜在线视频| 555夜色666亚洲国产免| 欧美一区二区三区免费视频 | 欧美一区二视频| 欧美日韩中文国产| 在线精品亚洲一区二区不卡| 成人app软件下载大全免费| 九一九一国产精品| 久久精品国产99国产精品| 午夜精品免费在线| 日本成人在线电影网| 午夜精品一区二区三区电影天堂 | 色综合天天综合给合国产| 激情av综合网| 99视频精品全部免费在线| 99视频精品免费视频| 成人午夜精品一区二区三区| 成人白浆超碰人人人人| 欧美午夜精品一区二区三区| 91福利精品视频| 日本韩国一区二区三区视频| 波多野结衣欧美| 久久噜噜亚洲综合| 国产精品毛片无遮挡高清| 亚洲乱码中文字幕综合| 喷白浆一区二区| 国产精品一区一区| 波波电影院一区二区三区| 国产精品一区二区久久不卡| 色综合天天综合狠狠| 欧美日韩二区三区| 日韩精品一区二区在线观看| 国产精品久久久久9999吃药| 亚洲乱码中文字幕| 免费一级欧美片在线观看| 国产乱一区二区|