My problem with fdopen and sockets........

King Su wen-king at cit-vax.Caltech.Edu
Wed Feb 15 01:27:17 AEST 1989


In article <7937 at netnews.upenn.edu> arup at grad1.cis.upenn.edu.UUCP (Arup Mukherjee) writes:
>
>To all net.wizards [again...] :

First of all, you should do a 'fflush' on the FILE after you wrote to it.
Since a socket file is not a character speical device, the FILE writing
functions such as fprintf will cause characters to be held in an internal
buffer until a buffering limit is reached or until you do a fflush.

Secondly, you do not need two sockets, you just need two FILEs.  You can
apply fdopen on the same file twice.  You don't need to dup it either.
For example:

in  = fdopen(soc,"r");
out = fdopen(soc,"w");

Your observation, that the suggestions you got by E-mail doesn't work,
probably is due to that fact that you did not use fflush.

-- 
/*------------------------------------------------------------------------*\
| Wen-King Su  wen-king at vlsi.caltech.edu  Caltech Corp of Cosmic Engineers |
\*------------------------------------------------------------------------*/



More information about the Comp.unix.wizards mailing list