- 论坛徽章:
- 0
|
小弟知不该如此发问,但实无良解,望有经验达人执教。亦望版主放行
code如下,用IE访问某些页面,socket(代码中conn_fd)居然不会被断掉,但用firefox却一切正常。socket不被断掉造成的结果是下一次连接不会开始。(比如websRedirect之类的动作)。
呜呼哀哉,IE缓存的原因?还是我们新加的webServer有待优化?头大了~~
- for (;;) {
- if ((conn_fd = accept(listen_fd, &usa.sa, &sz)) < 0) {
- perror("accept");
- return errno;
- }
- printf("==1>;conn_fd=%d ", conn_fd);
-
- if ( conn_fd == STDIN_FILENO || conn_fd == STDOUT_FILENO || conn_fd == STDERR_FILENO )
- {
- int newfd = dup2( conn_fd, STDERR_FILENO + 1 );
- if ( newfd >;= 0 )
- conn_fd = newfd;
- /* If the dup2 fails, shrug. We'll just take our chances.
- ** Shouldn't happen though.
- */
- }
- if (!(conn_fp = fdopen(conn_fd, "r+"))) {
- perror("fdopen");
- return errno;
- }
- Restore_connfd = conn_fd;
- tempfd=dup(conn_fd);
- handle_request(tempfd);
- fflush(conn_fp);
- fclose(conn_fp);
- close(tempfd);
- close(conn_fd);
- printf("==2>;conn_fd=%d\n", conn_fd);
- }
复制代码 |
|