So I am working on a homework project for my network architure class were I have to devlop an FTP program using UDP (not TCP). I was able to get my GET and PUT functions to send a 21byte test file and it worked. However when I tried to do a 1MB file the program hanged and did not send all of the data. I need to be able to send files of 1MB, 25MB, 50MB, and 100MB. Here is my code.
private static void getFile(String serverFilePath, String clientFilePath) throws IOException
{
clientFilePath = clientFilePath.replaceAll("^\"|\"$", ""); //Strip quotes if any.
if(!clientFilePath.startsWith("/"))
clientFilePath = currentDir + "/" + clientFilePath;
sendMessage("GET " + serverFilePath);
//Write file to client
try (FileOutputStream fos = new FileOutputStream(clientFilePath))
{
while (true)
{
byte[] buffer = new byte[BUFFER_SIZE];
DatagramPacket packet = new DatagramPacket(buffer, buffer.l