I have a Socket connection to an COM-Server ++ from W&T that is connected to the internet and also connected to my PC over Serial-to-USB.
The settings of the COM-Server for TCP outbound communication are:
Activ. Packet Options : disabled
Inactiv. Timeout : 00030
Connect. Timeout : 00300
Disconnect Char : 000
Client: "C"+Addr : disabled
Response Mode : disabled
In my application I read the incoming data of this server like this:
boolean running = true;
log.info( "{0}: Starting to listen for input data", name );
while ( running )
{
try
{
int charsRead = inputStream.read( buffer );
if ( charsRead < 0 )
{
running = false;
}
else
{
byte[] received = Arrays.copyOf( buffer, charsRead );
/** TODO: Call interface of protocol here */
log.info( "{0}: data received: {1}", connection.getName(), new String( received ) );
}
}
catch ( IOException ie )
{
setStatus( ConnectionStatus.FAILURE );
close();
/** TODO: Exception handling */
running = false;
}
}
If I send:test<CR><LF>
from the device the log output I get is:
(terminal1) terminal1: data received: t
(terminal1) terminal1: data received: e
(terminal1) terminal1: data received: st
(terminal1) terminal1: data received:
(terminal1) terminal1: data received:
The desired Output however is:
(terminal1) terminal1: data received: test
Where is my mistake or do I assume a false workflow of the read method of the InputStream?