主要就是实现的程序模块化,实现了一个基本档案关系系统,并且有许多的账户可以注册,管理员可以修改其中的内容,有兴趣可以自己打开看看,文尾链接内饰我的代码,感兴趣可以看看,完全分享
主要服务端代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| public Server() throws IOException{ InetAddress liushen = InetAddress.getLocalHost(); String s = liushen.getHostAddress(); System.out.println("地址嗷嗷嗷为:"+s); server = new ServerSocket( 12345, 100 ); int number=1; while(true){ displayMessage( "正在等待设备……\n" ); Socket connection = server.accept(); displayMessage( "连接 " + number + " 已经从此处建立连接:" + connection.getInetAddress().getHostName() ); new ServerThread(connection,"Thread"+number++); } }
|
除此之外,还有客户端:
1 2 3 4 5 6 7 8 9 10 11 12 13
| public void runClient() throws IOException { try{ connectToSerever(); getStreams(); processConnection(); } catch(EOFException eofException) { displayMessage("\nClient termined connection"); } catch(IOException ioException) { ioException.printStackTrace(); } finally { closeConnection(); } }
|
具体代码比较多,这里就不再细讲,完整程序可以看我的Gitee文件
Java程序设计实验报告