title: Problem with C server socket connected to Java client
body: <p>I am writing an application on Android, and I want it to be able to know when the server (which I have written in C) dies or is shutdown. I am trying to implement this by having the server send a message to the client (the Android app) at a specified interval. If this message doesn't come, then the client knows that it is no longer connected to the server. They communicate using TCP sockets. </p>
  
  <p>My problem is that the Android app cannot seem to read what the server writes. When it gets to the first part of the code where it tries to read from the server socket, it just hangs. In the Android app I am using a BufferedReader to read from the socket <code>tmpstr = inFromServer.readLine();</code> where tmpstr is a string and inFromServer is the BufferedReader, and the C server is just using write <code>write(newsockfd,"I got your message",18);</code>. </p>
  
  <p>I also tried using an alternative java server to see if my basic program logic was wrong. The test server used a PrintWriter, and it worked perfectly with the Android client.</p>
  
  <p>What am I missing here? Is there a difference in the way Java and C buffer (or don't buffer) their data? If I need to give any additional information, please let me know.</p>
  
  <p>Edit: I also have no trouble getting the C server to read data sent from the client. I only have trouble with getting the client to read data that is sent from the server.</p>
  
  <p>Edit: The problem was fixed by adding a newline character (<code>\n</code>) to what the server sends to the client. </p>