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

📄 main.java

📁 酒店服务器端程序
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package hotelserver;import java.io.*;import java.net.*;import java.util.Properties;/** * * @author Administrator */public class Main {    /**     * @param args the command line arguments     */    public static void main(String[] args)     {        hsJFrame h=new hsJFrame();        h.setVisible(true);                        //开始服务                        Socket sforc=null;        Socket sforb=null;        ServerSocket ssforc=null;        ServerSocket ssforb=null;                InputStream inforc=null;        OutputStream outforc=null;        InputStream inforb=null;        OutputStream outforb=null;                        Properties inpforc=null;        Properties inpforb=null;        Properties outpforb=null;                        int portforc=10000;        int bankport=10001;        String bankip="127.0.0.1";//////////////////////////////////////////////////////////////////////////                        try{            ssforc=new ServerSocket(portforc);           }        catch(IOException e)        {            //输出错误信息        }                        while(true)        {            try            {                sforc=ssforc.accept();                                inforc=sforc.getInputStream();                                inpforc.load(inforc);                         //取得了client的properties                                 //hotelserver.hsJFrame.jianshiqi.setText("有请求送到\n");                                sforb=new Socket(bankip,bankport);                                inforb=sforb.getInputStream();                outforb=sforb.getOutputStream();                                outpforb.setProperty("type", "dm");                outpforb.setProperty("id1", inpforc.getProperty("id"));                outpforb.setProperty("m",inpforc.getProperty("m"));                                outpforb.store(outforb, "");                                inpforb.load(inforb);                                                inpforb.store(outforc,"");//向客户端发送回复                                if(inpforb.getProperty("type").matches("rok"))                {                   //输出请求成功处理                }                else                {                   //输出请求处理失败                }                                                //关闭连接                                inforc.close();                outforc.close();                                inforb.close();                outforb.close();                                sforc.close();                sforb.close();                                                               }            catch(Exception e)            {                //            }        }                                       }}

⌨️ 快捷键说明

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