fmlclient.java

来自「农业银行ATM对帐查询系统后台类包的源代码,实现了FTP,数据库管理等等功能」· Java 代码 · 共 81 行

JAVA
81
字号
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 + =
减小字号Ctrl + -
显示快捷键?