MATLAB: Tcpip does not recognize LF terminator

MATLABtcpip terminator

Am using matlab tcpip in server mode:
t=tcpip('192.168.15.168',2055,'NetworkRole','server','Terminator','LF')
fopen(t)
commands = fscanf(t,'%s',40);
Client is Labview 6 running on Mac OS9 on Mac G4. Mac sends 40 characters, last of which is linefeed. Labview acknowledges that all characters were sent. Matlab times out in fscanf function, claiming no terminator found. Why?

Best Answer

I found the answer to my problem at the following site: http://stackoverflow.com/questions/20468411/communication-between-matlab-and-c-using-sockets?rq=1 In a nutshell, the problem is that it takes time for MatLab to prepare for a read operation after the fopen handshaking is done. When the client writes data immediately after fopen, the data arrives to soon. Inserting at least a 40msec delay between the client's fopen and write operations was enough delay. I use 100msec just in case. Mathworks could eliminate this problem, which has vexed numerous users, by having the server prepare the command following fopen (a read operation in my case) before fopen is executed, so that the read operation is prepared when the client data arrives.
Related Question