- /server -> server program related sources
- /client -> client program related sources
- /common -> common inclusions
- /util -> common utilization
- /build -> target build directory
Code out your /server/server.c
and /client/client.c
, then
$ make
Test your /build/server
and build/client
.
- Use
pthread_t threads[10]
array andbool *thread_sum
array to record the pthread - Once server
accept
the client, the server usepthread_create
to carry out the multi-thread. - If Clients are up to 10, the server will not accept new client.
- Use
pthread_mutex_lock
andpthread_mutex_unlock
to avoid race condition.
typedef struct HashNode
{
struct HashNode* next;
char *key;
char *value;
} HashNode;
- Use Hash Table as the DataBase. a linked list array (size = 26)
int Hashing (char* Key);
: Use Key to create Hash value (0-25)HashNode* HashNode_Create(char *Key, char *Value);
Create a Link-list NodeHashNode* HashNode_Insert(HashNode* Root, char* Key,char* Value);
: Save K-V pair to Hash Table (as a linked list).HashNode* HashNode_Search(HashNode* Root,char *Key);
: Search the Key and Return Value.HashNode* HashNode_Delete(HashNode* Root,char *Key);
: Delete the K-V pair.