All,
so I came up with a simple protocol that I want to use to interact with the client server. This is a typical (I think) three-phase layout:
- Connection Connection (will eventually include feature negotiation)
- Actual data exchange - packets happily move back and forth, "are interpreted by the corresponding receiver, which acts on them accordingly.
- Connection Teardown - one side says: “I don’t want anymore”, the other side says “so be it” (ultimately it will allow the other side to send some data until this is done, and not just close the conversation)
The structure is a simple setup: the server executes java.net.ServerSocket.accept () and starts the thread to process the incoming connection by the client, which creates java.net.Socket () for the host / port where the server is waiting. Both parties use java.io.InputStream and java.io.OutputStream and output data to each other, collecting outgoing and analyzing incoming messages. Okay bye.
While the protocol is hardcoded. Establishing a connection and Teardown is pretty good, while the part of the data exchange that I want to be full duplex is pretty much a mess.
, , - , , , . , , , , . good - , . , .
, ... . , (, ) ? , 1- 3- , .
, , .
, C/++/# - Java ( , ).