CodeBlanks Logo Icon CodeBlanks

Project design

Design the skeleton of the advanced final mini app.

Project: Mini server

In this five-lesson project you'll build a mini server. Each lesson adds a layer; by the final lesson you'll have a working program that combines fork/pthread, sockets and IPC.

You'll use what you learned in earlier groups: fork, pthread, sockets and pipe. Throughout the project you'll define four functions: worker_init, server_setup, ipc_setup and server_run. In this first lesson you'll lay out the module skeleton: prototypes and main.

Module skeleton

Large C projects start with prototypes. int worker_init(void); is a declaration; the definition may be in another file or below. With the declaration the compiler knows the function exists.

In this project you'll define four prototypes: worker_init (process/thread layer), server_setup (socket layer), ipc_setup (IPC layer) and in the final lesson server_run (integration). The first lesson starts with only the first three prototypes and a main that prints printf("Proje hazır\n");.

Practice Write the skeleton

Add three prototypes: int worker_init(void);, int server_setup(void);, int ipc_setup(void);. Write int main(void) and inside it print printf("Proje hazır\n");.

Starter code

main.c
#include <stdio.h>

// Proje: mini sunucu (fork/pthread + soket + IPC)
// worker_init, server_setup, ipc_setup prototiplerini ekle
// main: "Proje hazır" yazdır

Sample solution

main.c
#include <stdio.h>

int worker_init(void);
int server_setup(void);
int ipc_setup(void);

int main(void) {
    printf("Proje hazır\n");
    return 0;
}

Expected output

Proje hazır

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Which layers does the project include?

  • Only printf
  • Only file I/O
  • Process + socket + IPC Correct answer
  • Only loops

Explanation: The project combines fork/pthread, socket and IPC layers.

2 worker_init prototype

Question
int worker_init(____);
Answer
int worker_init(void);

Explanation: worker_init(void) is a parameterless function.

3 Match the layers

Term Meaning
worker_init Process/thread
server_setup Socket
ipc_setup Pipe IPC
server_run Integration

All lessons in Advanced