linux - Server handling multiple clients - C Systems Programming -



linux - Server handling multiple clients - C Systems Programming -

i have server, containing file.txt. have multiple clients can read/write file(found on server). wish lock other write requests, when write request beingness handled. however, read requests never locked. know, best handle such race conditions? thinking can tackle having struct each client in server, each struct contains "ip address of client", , "flag enabling write client" , sort of mutexes. hope clear plenty :) appreciate feedback!

it sounds want reader-writer locks. fact actual readers , writers remote clients minor detail, since actual readers , writers threads on server side.

the linked wikipedia articles mentions pthread_rwlock_t, defined posix , should available through pthreads on modern linux distributions.

update: based on op's comment, trying synchronize file access across processes. implies should using flock, caveats mentioned in this answer.

c linux client-server

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -