title: TCP/IP communication between Matlab and C++
body: <p>I have problem in TCP/IP communication between Matlab and C++. I create a server in C++ using <code>MWinsock</code>, that can send and receive data from client. In Matlab (acts as client), I create TCP/IP object, connect to server, and use <code>fprintf</code> to send a text to server [for example, I send text "A005" to server, <code>fprintf(t, 'A005')</code>]. 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! </p>
  
  <hr>
  
  <p>Thank you for your answers,
  The codes are actually simple</p>
  
  <p>*In Matlab, use TCP/IP object:</p>
  
  <pre><code>t = tcpip('IPaddress', 1200); %IPaddress get from server after running 'winServer.exe' file.
  fopen(t);  
  fprintf(t, 'A005')
  </code></pre>
  
  <p>*On the server, I use server file developed by LiyangYu (you may download .exe file from <a href="http://www.codeproject.com/Articles/7108/A-light-weighted-client-server-socket-class-in-C" rel="nofollow">here</a>).</p>
  
  <p>I tried and got problem as described above, so could you give any solutions? 
  Thank you!</p>