Let me please add another important (I think) bit of information. In
my previous mail I reported that a call to fork() is essential to
reproduce the weird read()/write() problem. It turns out that only the
child is affected. If I modify the server to let the parent answer the
client request after forking, everything is fine again. This should
IMHO rule out any timing related issues.

A small change to server program will do the trick:
------------------------------------------------------
--- server5b.c  Fri Dec  8 16:49:27 2000
+++ server5c.c  Fri Dec  8 21:55:46 2000
@@ -52,22 +52,22 @@
          printf("adding client on fd %d\n", client_sockfd);
        }
        else {
-         if (fork() == 0) { /* child */
+         if (fork() != 0) { /* parent */
            iread(fd, ch, 10);
            sleep(1);
-           printf("child serving client on fd %d; ch=%s<<\n", fd, ch);
+           printf("parent serving client on fd %d; ch=%s<<\n", fd, ch);
            ch[0]++;
            iwrite(fd, ch, 5);
            iwrite(fd, ch+5, 5);
            close(fd);
            FD_CLR(fd, &readfds);
-           printf("child done on fd %d; ch=%s<<\n", fd, ch);
-           exit(0);
+           printf("parent done on fd %d; ch=%s<<\n", fd, ch);
          }
-         else { /* parent */
+         else { /* child */
            close(fd);
            FD_CLR(fd, &readfds);
-           printf("parent done on fd %d\n", fd);
+           printf("child done on fd %d\n", fd);
+           exit(0);
          }
        }
       }
------------------------------------------------------

So my (un)educated guess is that it is less a read()/write() problem
per se but rather a problem how an inherited socket is set up in the
child process after forking.

regards,
Markus

-- 
Markus Hoenicka, PhD
UT Houston Medical School
Dept. of Integrative Biology and Pharmacology
6431 Fannin MSB4.114
Houston, TX 77030
(713) 500-6313, -7477
(713) 500-7444 (fax)
[EMAIL PROTECTED]
http://ourworld.compuserve.com/homepages/hoenicka_markus/


--
Want to unsubscribe from this list?
Send a message to [EMAIL PROTECTED]

Reply via email to