The EMFILE means an out of socket ports error. This error occurs if allocation of a port structure fails during a call to socket in host-target communication. If host target communication is significant in a model execution, EMLFILE error is expected.
There are several ways in to make the host communicate less frequently to the target. The following are enumerated below:
1. The best way is to use multicore kernel on a multicore target machine. Using a single core target is vulnerable to running into this state. The reason is that with multicore kernel the communication is not disrupted between host and target during a TCP/IP communication, therefore the host and target don't need to close and open another ports.
2. In the model, if there is a scope an output collected from the target, watching such a scope on the host via external mode generates a lot of host-target traffic. Use an xPC target scope, which displays the same result on the target screen.
3. Make the communication timeout much longer than the model stop time. This is because when a model is run under polling mode, it disables the interrupts to occupy the CPU, and then enables interrupts after the execution. When the interrupts are disabled during the execution, the target is unable to communicate with the host, host gets a communication error "TCP/IP timeout
while receiving data". Say, when we issue commands to modify the model parameters using XPCEXPLR, the host and target have to re-establish communication via different ports. This is why EMFILE error intermittently occurs.
You may accomplish this in the following way:
Say the stop time of the model is 5 seconds, first, set the communication timeOut to be 5, and host shows a timeout error right after the command
tg = xpctarget.xpc
tg.CommunicationTimeOut = 5;
tg.load('MySimpleMuscleModelNaDCET');
+tg;
The following error may occur:
Error using start (line 22)
TargetPC1: TCP/IP timeout while receiving data
Further, change the communication timeout to 50, host works fine.
xpctargetping;
tg.CommunicationTimeOut = 50;
+tg;
Output is:
Another important thing to note is that, to issue the command XPCTARGETPING before sending commands to modify parameter. XPCTARGETPING can reconnect the target if the communication is lost.
Best Answer