Rolando Andrade
Back to projects

Built in 2020

UCAB Cloud

Storage Cloud Client and Server

UCAB Cloud preview

Linux Desktop FTP client and server, each tool with a graphic user interface and a console interface. It uses vanilla POSIX sockets.

Most developers never write network code at the socket level. A socket is the operating system’s endpoint for a network connection. Modern frameworks hide it. You call an HTTP library, and data appears. You never see the connection itself.

In my Computer Networks II course, the assignment was to build an FTP system from scratch. FTP (File Transfer Protocol) is an old, standard way to move files between computers. It was my chance to see how networked programs work underneath.

I went beyond the requirements. The course asked for a command line tool. I built a full cloud storage suite instead: a client and a server, each with a graphical interface and a console version.

A server and a client

UCAB Cloud is a file transfer system built on FTP. The server runs on a port you choose and serves many clients at the same time. A client connects, logs in, and manages files on the server.

The server is a desktop app. An administrator uses it to start and stop the FTP service. They can manage users, set each user’s home folder, and see who is connected. Files and folders show up in a visual browser.

The client app looks like the server app. A user connects with a username and password, then moves around the remote folders. They can upload, download, create folders, rename items and delete them. The screen shows the current path and the details of each file.

Both tools also have console versions for computers without a graphical desktop. The same features work through text commands.

Raw sockets, no libraries

The whole network layer uses POSIX sockets directly. POSIX is the standard set of system calls that Linux and other Unix systems share. I used no networking libraries and no HTTP wrappers. Every connection is a raw system call.

My code covers the full life of a socket. It creates the socket, binds it to a port, listens, and accepts clients. Then it sends data, receives data, and closes the connection. Each step is a direct call to the operating system.

The server uses TCP sockets, which deliver data reliably and in order. When a client connects, the server forks a new process for that session. Forking makes a copy of the running program. Each copy has its own socket and its own state, so one client’s problems cannot crash the others.

Speaking the FTP protocol

The server understands the core FTP commands:

  1. USER and PASS log the user in.
  2. PWD, CWD and LIST show the current folder, change folders and list files.
  3. STOR uploads a file, RETR downloads one, and MKD creates a folder.
  4. Custom commands handle rename and delete.

Passive mode helps clients that sit behind firewalls. With the PASV command, the server opens a new port and sends back its number in the standard FTP format. The client then connects to that port to move the data.

The server supports two transfer modes. Binary mode copies a file byte by byte with no changes. ASCII mode is for text files and converts line endings. The TYPE command switches between them.

One process per client

The main server process runs in a loop and accepts new connections. When a client arrives, fork creates a child process. The child talks to that client. The parent goes back to waiting for the next one.

This model keeps clients apart. Each one gets its own memory, file handles and state. A client that misbehaves cannot affect anyone else.

The shared user file was the tricky part. Several processes might read it at once. So the file stays read only during normal use. Only the administrator changes it, through the manager interface.

Two channels for every transfer

FTP uses two separate connections. The control channel carries commands and replies. The data channel carries file contents and folder listings.

For a download, the server reads the file in chunks and sends each chunk through the data socket. Each chunk is 2048 bytes. That size keeps memory use low and transfers fast. Large files stream through without ever loading fully into memory.

Uploads work the same way in reverse. The server receives chunks and writes them to disk. Binary mode keeps the file exactly as it was. When the transfer ends, the server sends a confirmation on the control channel.

A Qt Quick interface

I built the graphical interface with Qt Quick and QML. QML is a language where you describe what the screen looks like, not the steps to draw it. File browsers, user cards and navigation bars combine into full screens.

C++ classes give the QML layer its features:

  1. The server manager starts and stops the FTP process.
  2. The file manager lists folders and runs file operations.
  3. The user manager reads and edits the user file.

Qt’s signals and slots connect the two layers. A signal is a message one object sends, and a slot is the function that receives it. A click in QML calls a C++ method. The result comes back through property bindings, and the screen updates on its own when the data changes.

The app uses the Material design style. Buttons, headers and lists follow patterns people already know, so nobody has to learn a new way to use it.

Simple user accounts

Users log in against a plain text file. Each line holds a username, a password and a home folder path. The server reads this file on every login attempt.

After a successful login, the server moves into that user’s home folder. Every later operation happens inside it. Users cannot leave their own area.

Administrators manage accounts from the manager interface. They create users, set passwords and assign home folders. The changes are saved back to the file.

What libraries usually hide

Socket programming shows you everything a library would handle for you. A connection can fail at any point. Timeouts happen. Clients disconnect without warning. My code had to handle each case by hand.

FTP has its own quirks. Reply codes follow conventions, but real programs differ. The passive mode port needs an exact format. Folder listings need a specific layout, or clients cannot read them.

The interface and the network layer needed separate threads. A network call must never freeze the screen. So the server runs in its own thread, and signals carry messages between it and the interface thread.

Testing was hard too. The client and server have to run at the same time. Timing matters. Reproducing a rare bug takes careful setup.

What I took away

Every HTTP request you make ends up as socket operations. After UCAB Cloud, I know what happens at that layer, and that helps me debug strange connection problems.

The project also taught me why protocol standards matter. FTP clients expect exact reply formats. If you break the standard, other programs stop working with yours.

Process management in servers needs care. Forking keeps clients apart, but it adds work. You have to clean up resources, avoid zombie processes (finished child processes nobody cleaned up) and handle signals.

High level frameworks do the tedious parts for you. Knowing what they do underneath is what lets me fix them when they fail.

Interested in working together? Check out my services and pricing to see how we can collaborate on your next project. Let's Build