I have problem in TCP/IP communication between Matlab and C++. I create a server in C++ using MWinsock
, that can send and receive data from client. In Matlab (acts as client), I create TCP/IP object, connect to server, and use fprintf
to send a text to server [for example, I send text "A005" to server, fprintf(t, 'A005')
]. However, on server run in C++ just receive sometime empty text '' or only '05' or 'A0', sometimes is 'A005'. So, could anyone give some help on this problem, many thanks!
Thank you for your answers, The codes are actually simple
*In Matlab, use TCP/IP object:
t = tcpip('IPaddress', 1200); %IPaddress get from server after running 'winServer.exe' file.
fopen(t);
fprintf(t, 'A005')
*On the server, I use server file developed by LiyangYu (you may download .exe file from here).
I tried and got problem as described above, so could you give any solutions? Thank you!