[cs631apue] why does fd 4 get re-used?
jphillip
jphillip at stevens.edu
Sat Dec 8 14:50:17 EST 2012
Accept returns me a fd of 4. I fork a child to handle the connection
and in that child I call the open command to read from the requested
file. Open also returns a fd of 4 and I can no longer send a reply to
the socket which had fd 4. Any ideas why? here is some debug from my
program:
[file request.c, line 238]: Reading request from socket 4
[file request.c, line 295]: Received GET request
[file request.c, line 308]: DECODED URI=t1/xyz
[file request.c, line 352]: Got full request version 1.0
[file response.c, line 101]: REQUEST FOR HTTP FILE:
/home/jphillip/Final/sws/t1/xyz
[file response.c, line 35]: Open resource for read-only, open returned
fd=4
[file response.c, line 41]: allocated read buf of size 1048576 bytes
[file response.c, line 47]: read 27 bytes from file: THIS IS THE FILE
CONTENTS
[file response.c, line 70]: failed to write 27 bytes of file data to
socket fd 4: Bad file descriptor
More information about the cs631apue
mailing list