I have a(n apparantly obscure) problem with sockets.
---- What I am doing, in outline ------------------------------------------
bind ( main_sock, (struct sockaddr*) &server, sizeof (struct sockaddr_in))
listen ( main_sock, 10 )
while ( 1 )
{
request_socket = accept ( main_sock, (struct sockaddr*) &source, &i ) ;
socketStream = fdopen ( request_socket, "r+b" );
fgets ( request, BUFSIZ, socketStream );
fscanf ( socketStream, "%20s", &j );
i = fileno ( socketStream );
dup2 ( i, 0 );
dup2 ( i, 1 );
close ( request_socket );
fclose ( socketStream );
if ( fork () == 0 )
execl ( fullFilename, file + (*file == '/'), (char*)0 );
---------------------------------------------------------------------------Quote:}
The fork'd child process will not read from stdin. I fdopen the socket
because I want to use formated io.
Prior to having the i=fileno, and dup'ing from i, I dup'ed the request_socket.
When I put in the 'i' line, it worked for the afternoon. That evening, it
no longer worked. Is there anything I should be aware of that I obviously
am not :) I am absolutely certain I changed nothing that could possibly impact
on io.
I know about having to seek after a write to avoiid undefined results, so I
tried seeking the socketSream (which seems stupid thing to do) and nothing
happened.
Thanks in advance,
Mark.