In Java, how would you set up a sockets listener, which speaks of a socket for a series of bytes, which is a command Represents and is called a method on receiving which parses incoming data and applies the proper command?
Explanation:
My problem is not with controlling the commands (whatever the error code or the answer to the command from the server) but to create a socket Hear it
More explanation:
What do I do Do.Net (C #) is a copy of the following line of code:
_stream.BeginRead (_data, 0, _data.Length, new asyncCallback (this.StreamEventHandler), _stream);
Where:
- _stream is a network stream created from a socket
- _data length is 9 bytes
- this.StreamHandler is a delegate (function pointer) that is executed when data is read.
I am rewriting a library in C in C # and currently writing the component TCPIP passes on a server command, but the above events / Reactions should also be able to bubble.
It looks trivial in C # and it looks less and less in Java. /p>
: The special part you requested is that section: "Magic goes here". It can be done in many ways in Oh, but there is one:
final inputstream in = socket.getInputStream (); // This request creates a new thread to serve new thread (new runnabal) (public zero-less) {byte [] retrieval data = new byte [ITEM_LENGTH]; In.read (recoverable data, 0, ITEM_LENGTH); In.close (); // Make your representative or some call here with some things to process data calls (Tethered Data);}}) Start ();
Comments
Post a Comment