public void run()
{
try
{
LengthProtocol protocol = new LengthProtocol();
while (true)
{
Socket socket = server.accept();
logger.debug("have connection " + count);
count.incrementAndGet();
InputStream stream = new BufferedInputStream(socket.getInputStream());
// repeat for as many messages as we receive until null received
while (true)
{
Object read = protocol.read(stream);
if (null == read)
{
break;
}
String msg = new String((byte[]) read);
logger.debug("read: " + msg);
logger.debug("writing reply");
protocol.write(socket.getOutputStream(), "ok");
}
}
}
catch (Exception e)
{