title: Java socket question
body: <p>I'm trying to write a simple server-client program, but I have a problem:
  I can send data from client to server, but I can't send data from the server (I can't recive it in the client) :(<br>
  So how to send data from the server, and recive it in the client?</p>
  
  <p>Server:</p>
  
  <pre><code>//this is in a thread
  try {
      server = new ServerSocket(1365);
  } catch (IOException e) {
      e.printStackTrace();
  }
  while (!exit) {
      try {
          clientSocket = server.accept();
          is = new DataInputStream(clientSocket.getInputStream());
          os = new PrintStream(clientSocket.getOutputStream());
          while ((line = is.readLine()) != null) {
              System.out.println("Message from client: " + line);
              //if (line.equals("exit")) {
              //  exit = true;
              //}
              if (line.equals("say something")) {
                  os.write("something".getBytes());
              }
          }
      } catch (IOException e) {
          e.printStackTrace();
      }
      try {
          is.close();
      } catch (IOException ex) {
          ex.printStackTrace();
      }
  os.close();
  }
  </code></pre>
  
  <p>Client:</p>
  
  <pre><code>try {
      socket = new Socket(host, 1365);
      os = new DataOutputStream(socket.getOutputStream());
      is = new DataInputStream(socket.getInputStream());
  } catch (UnknownHostException e) {}
  if (socket != null &amp;&amp; os != null &amp;&amp; is != null) {
      try {
          os.writeBytes("say something");
          //get the answer from server
          os.close();
          is.close();
          socket.close();
      } catch (IOException e) {}
  }
  </code></pre>
  
  <p>(sorry for the long code)<br>
  Thank you in advance.</p>