Date: Wed, 4 Feb 1998 10:53:59 +0200 (IST) From: Eli Zaretskii To: Gisle Vanem cc: djgpp AT delorie DOT com Subject: Re: FSEXT handles In-Reply-To: <199802031049.LAA15718@login-2.eunet.no> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk > I'm having trouble understanding how djgpp handles FSEXT'ensions when > duplicate handles exists. In general, duplicate handles should not exist. See below. > Lets say I create an handle X with socket() and install an extension > using __FSEXT_set_function (handle, func_parser). Note, socket() don't > use __FSEXT_add_open_handler(). > > At the same time I have an open DOS file with handle Y=X. I don't understand how did you get that handle Y which is equal to X. A file handle is not just an integer variable with an arbitrary value. Its value can only be produced by certain library functions which call DOS. These functions are `open' and its varieties (like `_open') and `dup'. If both `socket' and the other code which gave you handle Y used one of these functions, you can never have two different handles which have the same value, unless they are used to access the same file or device. That is because DOS always looks for a free handle when libc calls it. > How does e.g. _read() differentiate between them ? It doesn't. A handle is a unique id of an open file/device. That is why you must use one of the library functions that return handles. If the above somehow doesn't answer your question, post a small code snippet that shows what are you doing.