Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!sm.unisys.com!aero!elroy!cit-vax!wen-king From: wen-king@cit-vax.Caltech.Edu (King Su) Newsgroups: comp.unix.wizards Subject: Re: My problem with fdopen and sockets........ Message-ID: <9556@cit-vax.Caltech.Edu> Date: 14 Feb 89 15:27:17 GMT References: <7937@netnews.upenn.edu> Reply-To: wen-king@cit-vax.UUCP (Wen-King Su) Distribution: na Organization: California Institute of Technology Lines: 23 In article <7937@netnews.upenn.edu> arup@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@vlsi.caltech.edu Caltech Corp of Cosmic Engineers | \*------------------------------------------------------------------------*/