⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 serviceclient.java~33~

📁 短信网关发送接受平台。
💻 JAVA~33~
字号:
package Services;import Utilities.*;import java.util.*;import java.net.*;import java.io.*;import Config;/** * <p>Title: InHand SMS platform XMLRouter</p> * <p>Description: InHand 短信服务平台服务路由器</p> * <p>Copyright: Copyright (c) 2002</p> * <p>Company: 北京映翰通网络技术有限公司</p> * @author 韩传俊 shock2000@21cn.com * @version 1.0 */public class ServiceClient extends Engine {        ServiceInfo serviceInfo=null;        public DataInputStream in=null;        public PrintStream out=null;        public ServiceClient() {                super("serviceClient");        }        public boolean checkValid(Socket con){                try{                        String host=con.getInetAddress().toString();                        host=host.substring(1);                        System.out.println("in serviceclient.checkvalid(): "+host);                        ServiceInfo serviceInfo=null;                        for (int i=0;i<Config.subcode_item.size();i++){                                serviceInfo=(ServiceInfo)Config.subcode_item.elementAt(i);                                System.out.println("-----------------in serviceclient.checkvalid().subcode: "+serviceInfo.client_host);                                if (host.equalsIgnoreCase(serviceInfo.client_host)){                                        serviceInfo.setServiceClient(this);                                        this.serviceInfo=serviceInfo;                                        break;                                }                        }                        if(this.serviceInfo==null){                                for (int i=0;i<Config.service_id_item.size();i++){                                        serviceInfo=(ServiceInfo)Config.service_id_item.elementAt(i);                                        System.out.println("---------------in serviceclient.checkvalid().serviceInfo: "+serviceInfo.client_host);                                        if (host.equalsIgnoreCase(serviceInfo.client_host)){                                                serviceInfo.client=this;                                                this.serviceInfo=serviceInfo;                                                break;                                        }                                }                        }                        if(this.serviceInfo==null){                                con.close();                                Config.log.log("the connection from host:"+host+" is invalid!");                                System.out.println("the connection from host:"+host+" is invalid!");                                return false;                        }                        this.in=new DataInputStream(con.getInputStream());                        this.out=new PrintStream(con.getOutputStream());                }catch(Exception e){                        e.printStackTrace();                        Config.log.log(e,"while get input and output Stream in ServiceClient thread!");                }                return true;        }        public void run(){                String inStr="";                String outStr="";                if (this.serviceInfo==null){                        this.shutdown();                        nap();                }                try{                        while(isRunning()){                                if((inStr=this.in.readLine())!=null){                                        while (!Config.send_queue.push(inStr)) this.nap();                                }                                if (!this.serviceInfo.data.isEmpty()){                                        outStr=(String)this.serviceInfo.data.pop();                                        if (outStr!=null && !outStr.equalsIgnoreCase("")){                                                this.out.println(outStr);                                                //System.out.println("==============in processsubcode.processxmlstr().not null"+outStr);                                                if(str.startsWith("<cmpp_deliver"))                                                        System.out.println("read:"+str.substring(0,100)+"...");                                        }                                }                        }                }catch(Exception e){                        e.printStackTrace();                }finally{                        this.serviceInfo.client=null;                }                this.shutdown();        }        public static void main(String[] args) {                //ServiceClient serviceClient1 = new ServiceClient();        }}

⌨️ 快捷键说明

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