📄 fmlclient.java
字号:
package boco.transmonitor.fmlsocket;//******************************************************************************//:功能:发送数据测试程序//:时间:2002-07//:作者:王建宾//:特殊描述::test:为DEBUG时启用//:程序描述:// 可手动修改IP及端口号进行发送//******************************************************************************import java.net.*;import java.io.*;public class FmlClient {String host="127.0.0.1";int port=8888;Socket socket=null;protected DataInputStream inStream=null;protected DataOutputStream outStream=null; public FmlClient() { } public FmlClient(String host,int port) { try{ this.host=host; this.port=port; socket=new Socket(host,port); inStream=new DataInputStream(socket.getInputStream()); outStream=new DataOutputStream(socket.getOutputStream()); sendMessage("29999555567890133336789012345678901234567890123456789012345678901234567890"+ "1234567890123456789012345678901234567890123456789012345678901234567890"+ "1234567890123456789012345678901234567890123456789012345678901234567890"); } catch(Exception e) {System.out.println(e.toString());} } //开始进程 public void start() {String str=null; try{ while(true) { str=inStream.readUTF(); if(str.equals("no")) {socket.close(); } dataProcess(str); } } catch(Exception e) {System.out.println(e.toString());} finally{ try{ socket.close(); } catch(IOException e) {System.out.println(e.toString());} }} //数据处理方法 public void dataProcess(String message) { System.out.println("客户端收到报文:"+message); } //向客户端发送抱文 public void sendMessage(String msg) throws IOException { try{ outStream.writeUTF(msg);} catch(Exception e) {System.out.println(e.toString());} } public static void main(String[] args) { FmlClient client=new FmlClient("152.168.4.118",11001); client.start();}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -