title: Java and send file through socket
body: <p>I write a client-server application which will be sending an .xml file from the client to the server. I have a problem with sending large data. I notice that the server can get at most 1460 bytes. When I send a file with more than 1460 bytes the server gets only first 1460 bytes and nothng more. In effect I get uncompleted file. Here is my code:</p>
  
  <p>client send:</p>
  
  <pre><code>public void sendToServer(File file) throws Exception
  {
      OutputStream output = sk.getOutputStream();     
  
      FileInputStream fileInputStream = new FileInputStream(file);
      byte[] buffer = new byte[1024*1024];
      int bytesRead = 0;
  
      while((bytesRead = fileInputStream.read(buffer))&gt;0)
      {
          output.write(buffer,0,bytesRead);
      }
  
      fileInputStream.close();
  }
  </code></pre>
  
  <p>server get:</p>
  
  <pre><code>public File getFile(String name) throws Exception
  {
      File file=null;
  
      InputStream input = sk.getInputStream();
  
      file = new File("C://protokolPliki/" + name);
      FileOutputStream out = new FileOutputStream(file);
  
      byte[] buffer = new byte[1024*1024];
  
      int bytesReceived = 0;
  
      while((bytesReceived = input.read(buffer))&gt;0) {
          out.write(buffer,0,bytesReceived);
          System.out.println(bytesReceived);
          break;
      }
  
      return file;
  }
  </code></pre>
  
  <p>Do anyone know what is wrong with this code? Thanks for any help.</p>
  
  <p>EDIT:</p>
  
  <p>Nothing help :(. I google about that and I think its may connected with TCP MSS with is equal 1460 bytes.</p>