home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ukma!asuvax!ncar!vexcel!copper!slate!mbarkah
- From: mbarkah@slate.mines.colorado.edu (Ade Barkah)
- Newsgroups: comp.unix.programmer
- Subject: Re: client/server question.....
- Message-ID: <1993Jan28.195545.30826@slate.mines.colorado.edu>
- Date: 28 Jan 93 19:55:45 GMT
- References: <1993Jan27.223124.22279@aosg.gsf.dec.com>
- Organization: Colorado School of Mines
- Lines: 48
-
- Well, I don't know what the setup will look like (are you using
- sockets or STREAMS or non-of-the-above, will the clients be on
- the same machine, etc.) But, looking at the previous responses:
-
- 1) Making the temp file might be dangerous, especially from the
- original diagram it looks like there will be multiple main-
- clients updating the file. Unless you adopt a locking protocol,
- if two or more clients tries to update the file simultaneously,
- the result could be disastrous.
-
- 2) Same deal with threading, since it doesn't resolve simultaneous
- writes between different threads. On the side note, can someone
- email me about Unix threads ? I thought they didn't exists in
- most Unixes. I know Solaris has them.
-
- I guess there are really two problems here: a) communication between
- the clients and the server. b) interference between these when
- writing the datafile.
-
- If the main clients (the ones which will write) will reside in the
- same machine as the server, then problem a) and perhaps b) is
- easy to solve.
-
- For each main-clients, you can simply create named-pipes. One end
- of each pipe connects to the client, the other connects to the
- server. The server can poll the pipes periodically, you might be
- able to use select() or poll() to do this efficiently.
-
- But the server hangs when it tries to read the empty pipe. No
- problem. In unix, you can specify streams to be blocking when
- there is nothing to be read (default), or you can change the
- mode to non-blocking or no-delay. If you use the open() function
- call, then you can `open("named-pipe",PERMISSION|O_NONBLOCK)' or
- O_NDELAY as the case might be.
-
- If you don't use open to set non-block/no-delay, then you can
- still use the fcntl() function call. I think the form is
- fcntl (fildes, F_SETFL, O_NONBLOCK) (or O_NDELAY).
-
- It should be the server's responsibility to actually do the writing
- to the file. In that way, only one process performs writing, and
- thus you have resolved the concurrent interference problem.
-
-
- -Ade
- --
- Internet : mbarkah@slate.mines.colorado.edu (NeXT Mailable)
- CompuServe: 74160,3404
-