Sunday, April 29, 2012

Implimenting File Sever In Linux


                                          File server can be considered as administrative  storage of shared  resources in the network so that other terminals in the network can access to those resources.

              Here I am implimenting a multithreaded concurrent server.Multithreaded means seperate thread for each client request. One main thread (listen) will continiously run till there are client requests for the files.We have to create seperate thread to service each client request.Concurrent means that server can handle many client requests simultaneously.We also have to impliment mutual exclusion for shared resources.It means that simultaneous reading is possible but  reading while writing or writing while reading is not possible.
                  First we must run server code and then client code. After sucessfully conneted with client , server will display list of available files , will ask whether client want to read or write file  ? In both cases  server will send requested file to client and apply read/write lock on that file so that consistency must  be maintained.In my code ,server is opening file in read mode , reading it and then send it to client.At client end if client want to read the file , display  that file on terminal. If client is writing into file then that change must be reflected into file at server side.For next read request that updated file must be use.

            The main idea is to create socket connection first then we have to handle file read or write request .The functions that i have used for socket creation are  socket(),bind(),connect(),accept() etc and write() and read() for file manipulation.

No comments:

Post a Comment