Converting an fd (socket) to a FILE *.....

Arup Mukherjee arup at grad1.cis.upenn.edu
Mon Feb 13 15:33:59 AEST 1989


To all net.wizards :

	How does one convert an integer file descriptor to a FILE *
file pointer in the case where the fd describes a socket, and you want
to use the socket for *two-way* communication? The man page for
fdopen() says that it will perform this convertion for file
descriptors obtained from open(), dup(), creat() or pipe() - It says
nothing about the case when the fd came from socket(). I tried to use
it anyway - it works fine if you keep the flow of information one
way...but any attempts at two-way communication fail miserably. I have
tried using "r+" mode from fdopen(), as well as dup()'ing the file
descriptor and then calling fdopen with "r" for one and "w" for the
other. Neither method works.

Any help would be greatly appreciated....
						
					-Arup Mukherjee
					[arup at grasp.cis.upenn.edu]

P.S. I am using internet (AF_INET) sockets of type SOCK_STREAM. We are
running Ultrix 3.0.



More information about the Comp.unix.wizards mailing list