delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/04/15:01:22

From: Thomas Demmer <demmer AT LSTM DOT Ruhr-UNI-Bochum DOT De>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: FSEXT handles
Date: Wed, 04 Feb 1998 20:22:40 +0100
Organization: Lehrstuhl fuer Stroemungsmechanik
Lines: 38
Message-ID: <34D8C000.AA720907@LSTM.Ruhr-UNI-Bochum.De>
References: <199802041036 DOT LAA29383 AT login-2 DOT eunet DOT no>
NNTP-Posting-Host: bvb.lstm.ruhr-uni-bochum.de
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Gisle Vanem wrote:
[...] 
> Since `socket' doesn't call _open(), there is a chance that X=Y.
> Maybe I have to allocate the socket() handle using __FSEXT_alloc_fd()
> after all?
> 
That is exactly what it is meant for. 
On closing the socket, you'll need to say
...
case __FSEXT_close:
  clean_up_socket_stuff();
  __FSEXT_set_function(handle, NULL);
  *return_value = _close(handle);
  break; 

This first cleans up whatever needs to be cleaned up, 
then disconnects your handler function from the
FSEXT internal table, and the closes the file handle
you obtained from alloc_fd().
That function opens the NUL device to get a handle from DOS, 
and you must close it, otherwise DOS will run out of handles sooner
or later. The disconnecting has to happen before _close(), 
because otherwise _close() would call your handler again.

-- 
Ciao
Tom

*************************************************************
* Thomas Demmer                                             *
* Lehrstuhl fuer Stroemungsmechanik                         *
* Ruhr-Uni-Bochum                                           *
* Universitaetsstr. 150                                     *
* D-44780  Bochum                                           *
* Tel: +49 234 700 6434                                     *
* Fax: +49 234 709 4162                                     *
* http://www.lstm.ruhr-uni-bochum.de/~demmer                *
*************************************************************

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019