I still not decide using pthreads or fork for the server. If I chose fork, I need to use sharememory or semaphores or message to exchage data between processes. The server's duty are splitting the job to many little jobs, assigning ID to clients, assigning jobs to clients, collectting result from clients, and compute the final result. The clients get jobs from the server, compute the jobs, and return the result to the server. A client can do more than one jobs, if the server has more jobs than the clients.
Client only return one result for all the jobs assigned to it.
There are the files, but I am debuging. So sometimes it maybe not work. And the server still has some problem to communicate data between the process. After this version, maybe I will write another server using pthread. So I will add the PI function to the client now.