Lanky_Pomegranate530

joined 1 year ago
MODERATOR OF

I lowered the buffersize to 5 and sent the 21 byte test file and it was able to go through. However When I made the buffersize 3 (because my DONE packet was 4 bytes) is hanged and it appended the word DONE without the E.

 

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.

GET (Client Side)

 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.length);
                socket.receive(packet);

                String data = new String(packet.getData(), 0, packet.getLength());
                if (data.equals("DONE")) break;

                fos.write(packet.getData(), 0, packet.getLength());
            }
        }
        System.out.println("[Client] File downloaded successfully.");
    }

PUT (Client Side)

private static void putFile(String clientFilePath, String serverFilePath) throws IOException 
	{
        clientFilePath = clientFilePath.replaceAll("^\"|\"$", ""); //Strip quotes if any.
		if(!clientFilePath.startsWith("/"))
			clientFilePath = currentDir + "/" + clientFilePath;
			
		sendMessage("PUT " + serverFilePath);
		
		//Upload file to server
        try (FileInputStream fis = new FileInputStream(clientFilePath)) 
		{
            byte[] buffer = new byte[BUFFER_SIZE];
            int bytesRead;
            while ((bytesRead = fis.read(buffer)) != -1) 
			{
                DatagramPacket packet = new DatagramPacket(buffer, bytesRead, serverAddress, SERVER_PORT);
                socket.send(packet);
            }
            sendMessage("DONE");
        }
        System.out.println("[Client] File uploaded successfully.");
    }

GET (Server Side)

 private static void handleGet(String filePath, InetAddress clientAddress, int clientPort) throws IOException 
	{
        filePath = filePath.replaceAll("^\"|\"$", ""); //Strip quotes if any.
		if(!filePath.startsWith("/"))
			filePath = currentDir + "/" + filePath;
		
		//Check is file exists
		File file = new File(filePath);
        if (!file.exists()) 
		{
            sendMessage("[Server] Error File not found", clientAddress, clientPort);
            return;
        }
		
		//Write file to server
        try (FileInputStream fis = new FileInputStream(file)) 
		{
            byte[] buffer = new byte[BUFFER_SIZE];
            int bytesRead;
            while ((bytesRead = fis.read(buffer)) != -1) 
			{
                DatagramPacket packet = new DatagramPacket(buffer, bytesRead, clientAddress, clientPort);
                socket.send(packet);
            }
            sendMessage("DONE", clientAddress, clientPort);
        }
    }

PUT (Server Side)

private static void handlePut(String filePath, InetAddress clientAddress, int clientPort) throws IOException 
	{
        filePath = filePath.replaceAll("^\"|\"$", ""); //Strip quotes if any.
		if(!filePath.startsWith("/"))
			filePath = currentDir + "/" + filePath;
		
		File file = new File(filePath);
        try (FileOutputStream fos = new FileOutputStream(file)) 
		{
            while (true) 
			{
                byte[] buffer = new byte[BUFFER_SIZE];
                DatagramPacket packet = new DatagramPacket(buffer, buffer.length);
                socket.receive(packet);

                String data = new String(packet.getData(), 0, packet.getLength());
                if (data.equals("DONE")) break;

                fos.write(packet.getData(), 0, packet.getLength());
            }
        }
        sendMessage("DONE", clientAddress, clientPort);
    }
[–] Lanky_Pomegranate530@midwest.social 1 points 3 weeks ago (1 children)

You are right. The people who are saying that Jill Stein is a fascist clearly know nothing about her or her platform.

[–] Lanky_Pomegranate530@midwest.social 10 points 3 weeks ago (2 children)

Jill Stien only had 2% of the vote in 2016. That is nothing. Most of those people would have stayed home. The reason Hillary lost was because she was a bad canidiate who was unable to resonate with young voters.

Elon look so stupid.

 
[–] Lanky_Pomegranate530@midwest.social 4 points 2 months ago* (last edited 2 months ago) (1 children)

Thanks for linking me to the to this page. I did some more diging and I managed to figure out the actual problem. I was using a program called CompactGUI2 which allows you to use the NTFS file comprssion to save space. The minute I uncompressed the files from the Windows side I saw the Lock icons go away when I booted back into Linux.

[–] Lanky_Pomegranate530@midwest.social 2 points 2 months ago (3 children)

I mounted it using fstab

[–] Lanky_Pomegranate530@midwest.social 1 points 2 months ago* (last edited 2 months ago) (6 children)

I just download the appimage version of duckstation on the Linux side to see if it could run the game but it was unable to find my games in the ROMs Directory. Then I tried going to System > Start File and When I tried to launch the game that way I got this error.

What is even more weird is that I was able to launch the copy on my ext4 partition despite the fact the the BIOS I selected is in the ntfs partition.

Edit: I just tried opening the BIN and CUE files from the ntfs partition and got on error saying that the file does not exist despite the file being visible from the file manager. I also noticed that the one on the ntfs partition had some lock icons while the ext4 one did not. I also saw a windows directory in the cue file on the windows C: drive which I found very weird because I usually store all my games on the D: drive of my system. The copy on my ext4 also how this Windows Directory.

[–] Lanky_Pomegranate530@midwest.social 1 points 2 months ago (1 children)

I just installed the program but it says that it cannot find any devices.

[–] Lanky_Pomegranate530@midwest.social 1 points 2 months ago (8 children)

Do you mean like a different file manager? I just tried using Thunar instead of Nautilis and got the same error.

 

Ok I was copying a bunch of games from one of my Windows drives over to my phone while booted into Linux. And I got this error that says "libmtp error: Could not open source file". Thankfully I was able to copy the files when I was booted into Windows but it would be nice if I could Transfer files from my Windows drives without having to reboot into Windows. Is there a way I can fix this problem.

I think it might have to do with the ntfs file system because I copied one of the files from the phone back to my Desktop which is ext4 and then back to the phone without any issues. I already tried installing ntfs-3g which was already installed on my distro.

I disabled Windows update with winaero tweaker.

 

Long story short I was messing around in the terminal and messed up my Linux Mint Installation and now when I boot into Linux I only get a CLI and don't even see the Linux mint logo. I tried to restore to a previous state using Timeshift but it did not work so I ended up taking a live usb and backing up all my important documents to an external drive. I want to just do a fresh installation but unfortunally for me the boot drive is also the same drive I use to boot into Windows (which I am still able to boot into from GRUB). Is there a way I can reinstall the OS without affecting my ability to boot into Windows?

view more: next ›