@gbccccc first you need to define what "new slave is started successfully means".
If just binding to the port and waiting for connections is enough then you can assume that if you call the method and a ModbusInitException is thrown then it is not running. Otherwise it is bound to the port and waiting for connections.
If you want to know that something is connected you could extend the TcpSlave class like this:
public class MonitoredTcpSlave extends TcpSlave { public MonitoredTcpSlave(int port, boolean encapsulated) { super(port, encapsulated); } public boolean hasConnection() { return !listConnections.isEmpty(); } }As a last resort you could create your own TcpSlave by extending com.serotonin.modbus4j.ModbusSlaveSet.ModbusSlaveSet