result.setStatus(DatagramActionResultStatus.CAPTURED);
int readSize = definition.getExpectedResponse().length;
byte[] readBuffer = new byte[readSize];
DatagramPacket receivePacket = new DatagramPacket(readBuffer, 0, readSize);
try {
socket.receive(receivePacket);
} catch (InterruptedIOException e) {
result.setStatus(DatagramActionResultStatus.TIMEOUT);
}
if ((result.getStatus() == DatagramActionResultStatus.CAPTURED) && (receivePacket.getLength() > 0)) {
byte[] resultData = Arrays.copyOfRange(receivePacket.getData(),
receivePacket.getOffset(), receivePacket.getLength());
result.setResponse(resultData);
}
boolean succeed = (result.getStatus() == DatagramActionResultStatus.CAPTURED) &&
Arrays.equals(result.getResponse(), definition.getExpectedResponse());