• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Where can I find *simple* Java examples for FTP Server apps?

wasssup

Diamond Member
OK, so I have to design a full-fledged FTP server for one of my classes (with EVERYTHING implemented). I've googled away, and found full-fledged code, but believe it or not I actually want to learn (and do it on my own, for the most part). Thing is, I don't know how to get started (everything is in java, and i never took java before, though I have experience in C/C++). Anyway, anyone know where I could find something where it would at least give me an example of how to even start this?
 
here

and esp. here


I did the same project, and basically you start with understanding the protocol, which is basically is something with lines like STOR asdlaksdja ... four letters / space / other stuff here and responses like 200 Ok .. 3 numbers / space / human readable stuff here. In response to this you might also open up a second Socket and transfer files back and forth.

The simplest design is a multi-threaded design, where one thread handles all the communication in sequence with one user. I found the simplest output for a directory listing is probably the Bin/Ls format, although you have to form that output yourself in Java. You also have to invent some way to handle users logging in and out, since you don't have direct access to the system to log in and out. I created a sort of complicated system to handle / create user accounts that could handle any number of user directories. It might be simpler to only consider allow certain know directories or directory.

My stuff isn't exactly simple, but it's easier to understand than most C based FTP servers.
the main class is FTPServer which is a Thread which starts up instances of FTPServerThread which in turn each handle one particular session. UserGroupManager manages user information, and allows setup of the FTPServer. The user interface rides on top of an instance of FTPServer

my java ftp

doh just realized you don't know java.. but oh well the top two links will help
 
Start by writing a simple echo server. You want to use the java.net.ServerSocket class to accept incoming connections. Have it read incoming data, and write the exact same data to the server output stream. You can verify things are working properly with a standard telnet client.

Once you have the hang of reading/writing socket output, you can put the FTP protocol in place on top of the communication code.
 
thanks for the help guys, I really appreciate it...i'll check out those links in a few minutes.

*edit* i figured out my problem...i was running it off one of our campuses servers, but i had my client set to login to the other server...DUH! 🙂

 
Back
Top