title: golang Server with Java Client
body: <p>I have a big problem....
  We have a project on school and work as dou.
  I write the go server and my partner the java client.
  I have a problem that if he is sending something like: "Hello World" the golang server split this into "Hello" and "World"</p>
  
  <p><a href="http://i.stack.imgur.com/hJoUj.png" rel="nofollow">See Picture</a></p>
  
  <p>The Java Code:</p>
  
  <pre><code>public class DataController {
  public String recieveDataFromServer(Socket socket) throws Exception {
  
      BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
      while (!bufferedReader.ready()) { }
      String data = bufferedReader.readLine();
      return data;
  }
  
  public void sendDataToServer(Socket socket, String data) throws Exception
  {
      PrintWriter printWriter = new PrintWriter(socket.getOutputStream(), true);
      printWriter.println(data);
  }
  }
  </code></pre>
  
  <p>The go Code:</p>
  
  <pre><code>func handleRequest(conn net.Conn) {
  request := make([]byte, 256)
  
  for {
      _, err := conn.Read(request)
      if err != nil {
          Error.Println(err.Error())
          return
      }               
      Info.Println("Message Received: " + string(request))
      message := []byte(time.Now().String())
      message = append(message, []byte(": ")...)
      message = append(message, request...)
      broadcast(message)
  }
  }
  </code></pre>
  
  <p>The broadcast function just do a conn.Write(msg) for all the connections.</p>
  
  <p>Does anyone know that the problem is?</p>
  
  <p>Edit: I found the problem. Java add after each word a \r\n. Then the go server think the message ended. We switch now to c#. its easier and work correct while writing with a bufferedWriter to a socket.</p>