TCP/IP data formatting

The TCP/IP protocol allows for the communication or arbitrary bytes sequences. We have chosen to encode all of our data as string that is then serialized to bytes.

All messages have the same shape:

FLAG data Termination-bytes
 * The FLAG, always in capital letters, is here to tell UE4 or the python server what the message is about. The list of flags is ever expanding as we add modules. The current list of available flags is detailed under the List of Flags section.
 * The data can be anything, from int to float and string. It is defined individually for the needs of each module. Each piece of data is separated from the other by a single space.
 * The termination bytes is a sequence of 4 times 255. In UE4, the object deliverer add-on contains a method for sending sequences of arbitrary lengths, with a given sequence of termination bytes. This is very handy as we don't really know what amount of data we have to transmit. On the pyhton server side however, there is no native method to our knowledge that handles such arbitrary length TCP/IP messages. In order to compensate for that we have chosen to use overly long message length for reception, and then scan the byte sequence to find UE4-made termination bytes sequence. A better implementation would indeed be appreciated as requirements for larger molecules would mean that the message length to read to increase too much.

List of Flags

 * ECHO: tells the other part of the software that the current message is a copy of the received one. This can be used for debug and conformity check (check that the received message correpsonds to the sent one that is)
 * RUN: ask the python server whether relaxation is still running
 * ERROR: signals that something went wrong
 * RELAX: ask the server to start the relaxation
 * STOP: force stop all calculations on the server side
 * TRANSPORT: asks the server to start the transport calculation
 * REFINE_TRANSPORT: asks the server to refine the transport calculation by adding the specified extra points
 * TRANSPORT_COMPLETE: returns the completed transport calculation results to UE4
 * RELAX_COMPLETE: returns the completed relaxation calculation results to UE4
 * IMAGE: asks the server to start exporting graphs from the transport calculation
 * IMAGE_COMPLETE: tells UE4 that an image has been exported and the location at which it has been saved.