title: TFTP client does not recognize when last packet has been sent
body: <p>I'm using the mac TFTP client to work with my TFTP Java server. </p>
  
  <p>Whatever is requested from the client (in this case a txt file) is read and rewritten as it should. However I'm having a problem where the client doesn't seem to recognize that the last packet has been sent, in which case the session should be closed by the TFTP client (at least, as far as I know). </p>
  
  <p>This is the general code base for reading the requested file and checking if a packet is smaller than 512 bytes, in that case it should be the last packet and the client should close the session. Instead the client goes on until the Transfer Time has timed out. </p>
  
  <pre><code>int length = fileInputStream.read(buf);
  
      ByteBuffer wrap = ByteBuffer.allocate(BUFSIZE);
      wrap.putShort((short) OP_DAT);
      wrap.putShort((short) blockNumber );
      wrap.put(buf);
  
  
      DatagramPacket data = new DatagramPacket(wrap.array(), wrap.array().length);
  
      sendSocket.send(data);
      byte[] rec = new byte[BUFSIZE];
  
      DatagramPacket receivePacket = new DatagramPacket(rec, rec.length);
      sendSocket.receive(receivePacket);
      short comp = getAcknowledgment(receivePacket);
  
      if(comp == (short) blockNumber){
          System.out.println("Length of sent packet: " + length);
          return length &lt; 512;
      }
      return true;
  </code></pre>
  
  <p>If anyone has any experience with using the TFTP client on MAC OS X I would be very grateful for any advice. </p>