Hello,

I am currently working on a small project. I'm not looking for recruitment at the moment, rather just spreading word and ideas about my upcoming programming endeavors.

Project Overview
My current project, Dedicated, is a small dedicated server which consists of 5 categories:
  • Server handling
  • Client handling
  • Error handling
  • Configuration
  • Allocation

It has been under-development for nearly 2 months, and has performed well. It was written in the C language. I intend to make sure the build doesn’t produce one error or warning. Also, throughout all of the code I have error checking and improvise no memory leakage.


Project Details
» The Server handling category is the most crucial. I handle all incoming connections and data received with select(). Once a client connects, a new hash will be created within a dynamically created hash-table. The Server allows x amount of clients to connect, which is set to 8 automatically or manually if ran with the configuration options.

» The Client handling category handles all client information. It consists of a hash-table that is dynamically created. Each time a new client is stored, all other pertinent information is included in their node. Including IP, port, socket, name, etc…

» The Error handling category is more crucial than anything else. With detailed consideration, I have created a custom error handling system. This system works like fprintf(), whereas the first parameter can either be a warning or error. If found as an error, it will free all memory used [discussed in Allocation handling].

» The Configuration category is handy in almost any program. I allow people to see a detailed look at the configuration options by using the –help command:
Code:
usage: dedicated [options]
dedicated options:
    --config-file=file    configuration file
    --debug               debug allocation run-time
    --hunkSize=n          custom hunk size [MB]
    --slots=x             connection slots
    --conntype=TCP        connection type, i.e., UDP/TCP
    --port=10110          server port number
    --version             displays version
    --help                 for help
The current version my Dedicated is 0.1.3, and is solely maintained by me. I allow configuration files that look similar to the following:
Code:
#
# Dedicated Configuration
#

# Define a custom port
# All ports can range between 5000 and 50000
#port "10110"

# Server Connection Type
# TCP or UDP
#conn "TCP"

# Maximum amount of client slots
# Between 0 and 32
slots "6"         

# Run in debug mode
# Set to 1 or run with --debug flag
#debug "1"
The debug flag displays all allocations being made, including the free instances. This can be handy if any Segmentation Fault’s occur.

» The Allocation category was by far the most difficult. It has a working strategy, and has deemed useful in this project. The hunkSize option allows you to set an amount of space you want to pre-allocate. When the program is first executed, it splits the bytes in two and allocates memory to 2 heaps. If one heap exceeds its limit, it automatically switches to the other.

The allocation system works as it partitions out blocks of our memory heap, so we can re-use the same memory without further allocation from the core. Also, for error checking, I store all allocations made in a table so that I can check for duplicate addresses. Once freed, the memory can be used again appropriately. This alone took over 1 month to accomplish.

Overall, the project runs as a server. Clients can connect, and stored in a hash table. I can look them up, send data to them, and free the hash when finished. With allocation in mind, I created one function that will free all existing memory used within our heap for good practice. If anything fails, the program can automatically free all memory including the heaps.

When any error occurs, and I send a FATAL message to the program, all allocations will be freed accordingly. When executed with Valgrind, I receive little to no errors during run-time and when exited it reports no memory leaks or malloc’d blocks.


Conclusion
Another addition was to allow input from the server locally. So far, there are 2 commands that work: “connections” and “quit”. If ran in Debug mode, you can use the “allocation” command which will print the current amount of allocated bytes being used.

The project’s development is coming along nicely. It has been tested on Slackware 10.0 and GCC 3.4.3. With flags -O2, -Wall, -ansi, -pedantic, -pedantic-errors, and -std=c89 . No warnings and no errors. As of the time being, I’m out of ideas at the moment. I will soon purchase a UNIX Network Programming book to further improve my current operations. If anyone has any comments, or ideas, for my project please let me know. All feedback is welcomed.


- Stack Overflow