How to detach socket from FILE?

Sergei Organov osv at javad.ru
Thu Dec 6 16:41:35 UTC 2001


Suppose I've got socket descriptor and have attached it to a FILE using
'fdopen()'. Now I want to 'fclose()' the FILE, but leave socket
open. According to FreeBSD manual pages, 'fclose()' will close the socket.

I think I can do something like this:

int s;
FILE* file;
....
s = dup(fileno(file));
fclose(file);
... use s ...

But would 'dup' work as expected in RTEMS? Is there another/better way to
achieve the same goal?

Thanks in advance.

Sergei.




More information about the users mailing list