cmppsocket.java

来自「短信平台CMPP30 的JAVA程序,(含SQL数据库)」· Java 代码 · 共 120 行

JAVA
120
字号
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   CMPPSocket.java

package com.cmpp3_0.process;

import com.cmpp3_0.util.Logger;
import java.io.*;
import java.net.*;

public class CMPPSocket
{

    private String host;
    public InputStream in;
    public OutputStream out;
    private int port;
    private int seqId;
    private Socket socket;
    int timeOut;

    public CMPPSocket(Socket socket)
    {
        timeOut = 10000;
        this.socket = socket;
    }

    public CMPPSocket(String host, int port, int timeOut)
    {
        this.timeOut = 10000;
        this.host = host;
        this.port = port;
        this.timeOut = timeOut;
        socket = null;
        seqId = 1;
        out = null;
        in = null;
    }

    public int close()
    {
        int result = -1;
        if(socket != null)
            socket.close();
        result = 0;
        break MISSING_BLOCK_LABEL_38;
        IOException ie;
        ie;
        Logger.writeLog(-1, "socket::close-----关闭Socket时碰到IOException!", "cmpp");
        result = -209;
        return result;
        return result;
    }

    public int getSequenceId()
    {
        return seqId;
    }

    public int init()
    {
        int result = 0;
        if(socket == null)
            socket = new Socket(host, port);
        socket.setSoTimeout(timeOut);
        out = socket.getOutputStream();
        in = new DataInputStream(socket.getInputStream());
        break MISSING_BLOCK_LABEL_205;
        UnknownHostException uhe;
        uhe;
        socket = null;
        Logger.writeLog(-2, "socket::init-----" + host + "不是一个合法的主机地址 -或- 主机未开机 -或- 网络不畅通---找不到主机,不能初始化Socket!", "cmpp");
        result = -2;
        return result;
        ConnectException ce;
        ce;
        socket = null;
        Logger.writeLog(-2, "socket::init-----初始化时碰到ConnectException,可能网络不通,或ISMG主机地址无效!!---不能初始化Socket!", "cmpp");
        result = -3;
        return result;
        SocketException ste;
        ste;
        socket = null;
        Logger.writeLog(-2, "socket::init-----初始化时碰到SocketException----可能是TCP/IP连接出现错误--不能初始化Socket!", "cmpp");
        result = -4;
        return result;
        IOException ie;
        ie;
        socket = null;
        Logger.writeLog(-2, "socket::init-----初始化时碰到IOException--可能是端口无效,不能初始化Socket!", "cmpp");
        result = -5;
        return result;
        Exception e;
        e;
        socket = null;
        Logger.writeLog(-2, "socket::init-----初始化时碰到Exception,不能初始化Socket!", "cmpp");
        result = -6;
        return result;
        return result;
    }

    public boolean isSocketValid()
    {
        if(socket == null)
            return false;
        DataInputStream in = new DataInputStream(socket.getInputStream());
        break MISSING_BLOCK_LABEL_31;
        Exception e;
        e;
        return false;
        return true;
    }

    public void setSequenceId(int seqId)
    {
        this.seqId = seqId;
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?