Hi,
I want to integrate via Spring integration.
My standalone program connects to a ip address and port.
I write String commands to the socket. For example: "S*1,2,3,4;" always ended with the ';' character
And in a thread I read the incoming commands from server. All incoming commands are als Strings that ends with the ';' character.
In standalone code like this:
Sending data to socket:
Reading data from socket in thread:Code:String command = "!@@@!!@!@!@!@;" this.socket = new Socket(this.host, this.port); this.in = this.socket.getInputStream(); this.outputStreamWriter = new OutputStreamWriter(this.socket.getOutputStream()); this.reader = new BufferedReader( new InputStreamReader(this.in, "UTF-8")); this.outputStreamWriter.write(command, 0, command.length());
Now I want to integrate this functionallity in my spring appliction.Code:String buffer = ""; int character = this.reader.read(); String c = String.valueOf((char) character); c.trim(); if (!c.equals(";")) { buffer = buffer + c; } else { buffer = buffer + c; String command = buffer; //do something buffer = ""; }
I can use this:
http://xebee.xebia.in/2010/11/01/dat...g-integration/
But I don't found an example how to write my custom class to write and read the socket.
Can someone help me with that?
custom-socket-reader-class-name="CustomClass"
custom-socket-writer-class-name="CustomClass"


Reply With Quote