delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/08/21:00:16

Date: Fri, 9 Jul 1999 00:45:55 +0200 (MET DST)
From: Gisle Vanem <giva AT bryggen DOT bgnett DOT no>
To: djgpp AT delorie DOT com
Subject: fdopen() and FSEXT'ensions
Message-ID: <Pine.UW2.3.95.990709004521.28688A-100000@bryggen.bgnett.no>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com

I've made an FSEXT'ension handler for network socket I/O.
Now I which to tie a socket to a 'FILE*' in order to use fgets(),
fprintf() etc. with the sockets. But looking at fdopen() or setmode(),
FSEXT'ension handlers aren't called. I would think that my handler
would get an '__FSEXT_open' command, but it never does. Is this
intentional or an oversight?
 
My code looks something like this:
 
  s = socket (AF_INET, SOCK_DGRAM, 0)
     in socket():  __FSEXT_set_function (s, _fsext_demux);
 
  fil = fdopen (s,"r+");
 
  bind(), connect() etc.
 
  if (fprintf(fil, "HELO %s\r\n", _hostname) < 0)
  {
    perror ("fprintf");
    exit (-1);
  }
 
The program always gives me fil=NULL and errno=EBADF.
What special tricks do I need to use a socket with stream functions?

Gisle V.

- Raw text -


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