Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com From: "Markus Hoenicka" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="z1KCTocaUN" Content-Transfer-Encoding: 7bit Message-ID: <14897.6083.288000.828853@gargle.gargle.HOWL> Date: Fri, 8 Dec 2000 17:17:55 +0000 (CT0) To: Corinna Vinschen Subject: Re: socket read()/write() problem in 1.1.6 In-Reply-To: <00120813285702.12851@cygbert> References: <1529f1887b DOT 1887b1529f AT uth DOT tmc DOT edu> <00120813285702 DOT 12851 AT cygbert> X-Mailer: VM 6.75 under Emacs 20.6.1 --z1KCTocaUN Content-Type: text/plain; charset=us-ascii Content-Description: message body text Content-Transfer-Encoding: 7bit Hi, Corinna Vinschen writes: > AFAICS, the problem is that you rely on the speed of the connection. > The `read' call on the socket returning only 5 bytes while you're > expecting 10 is doing nothing wrong. Let me explain: > I have to keep on apologizing. I messed up the testcase that I sent. While it nicely demonstrated the speed gains in the socket communication that you thoroughly described, the files were wrong. > So, your `read' code should not look like this: > > read(sockfd, chin, 10); > > but rather look like that (assuming you expect receiving 10 bytes): > > len = 0; > do { > i = read(sockfd, chin + len, 10); > } while (i > 0 && (len += i) < 10); > This is what I *intended* to do. The example should use iread() instead of read() and iwrite() instead of write(). Those wrappers do something like you suggest, but they will eventually time out in case of network problems instead of looping forever. The funny thing is, that with these wrappers in place my "testcase" fails to demonstrate the problem :-/ So I started to prune back my original app and to extend the testcase until somewhere the problem goes away or appears, respectively. It turns out that I need to let the server fork in order to show the problem. Please find the modified 3kb testcase attached (I am down on my knees praying that it's correct this time). The only changes to the previous version are: client: actually calls the wrappers instead of calling read()/write() server: actually calls the wrappers instead of calling read()/write() forks before handling the client request. The screenshots look like this: cygwin1.dll 1.1.4: $ ./server5b & [1] 1006 mhoenicka AT GIRCH19 ~/prog/socket $ server waiting ./client3a char to server = 123456789 adding client on fd 4 server waiting iwrite:10<< parent done on fd 4 server waiting iread:10<< child serving client on fd 4; ch=123456789<< iwrite:5<< iwrite:5<< client: error 0 iread:10<< char from server = 223456789 child done on fd 4; ch=223456789<< cygwin1.dll 1.1.6: $ ./server5b & [1] 299 mhoenicka AT GIRCH19 ~/prog/socket $ server waiting $ ./client3a char to server = 123456789 adding client on fd 4 server waiting iwrite:10<< parent done on fd 4 server waiting iread:10<< child serving client on fd 4; ch=123456789<< iwrite:5<< iwrite:5<< child done on fd 4; ch=223456789<< client: Connection reset by peer iread:5<< char from server = 2234500000 so here we go again with the "connection reset" problem. As far as I understand your explanations I should get a different error if this again would be a timing problem (e.g. EINTR) in spite of the wrappers that should prevent exactly this. BTW those wrappers are almost identical to functions in GNU wget so I think they're not bogus. Again, your help is greatly appreciated. Markus --z1KCTocaUN Content-Type: application/x-gzip Content-Description: sockettest1.tar.gz Content-Disposition: attachment; filename="sockettest1.tar.gz" Content-Transfer-Encoding: base64 H4sIAN8WMToAA+1ZbVMbORLOV6jiP/SRStYGB2zA+BInu+UFs3EdMZQxxWbvtnzyjAarGM94 Z2QS7xb//bpbmvGMMQlcEvZeRqkAI7Va3a3W062WEwaBdPTW6Mm3a9Vatbq/t/ekWq3u7Nbr 9Bt7avSb2k6thn2NWq2xt1vfbyBdbWe3uvcEqt9QprRNYy0igCfjUSgD5VyJO+i6YSAfQ55H btsbcCgdX0RCqzCIwQsjcKxPrK0CwEE4mUXqcqShdFCG2suX9Qr93OefDTiKpISz0NMfRCTh KJwGLnOqQCdwkMPaan+kkK3yJeDvWIe+DEAELoxDV3lKuuBF4RguLqWek0+i8DISY5rh0QKx XaAJs3AKjgggkq6KdaSGU42MNXHcRtGZ6WxtFXtQEhmBHknQMhrHEHr88VP3HH6SgYyED6fT oa8cOFaODGIJAhemnniEUg2RC9HfpWATpMLxCK5lFOM37CQrWHYVCKO11ZLQJHME4YRmlVHQ GfhCzycu1XqunAsqYLajcIKqjJAf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Ph9RwXwsx54z+tsLKKuaKTLPK/3ZGnVRDS6qwUU1uKgGF9XgohpcVIMftxpc FIP/p4vBNmc02eJ6Pm0rKsRFhbioEBcV4m9XIS4KxEWB+AEF4v+wEnHRila0ohWtaEUrWtGK VrSiFa1oRSta0YpWtKIVrWhF+y9r/wJNL2NQAFAAAA== --z1KCTocaUN Content-Type: text/plain; charset=us-ascii Content-Description: .signature Content-Transfer-Encoding: 7bit -- 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) Markus DOT Hoenicka AT uth DOT tmc DOT edu http://ourworld.compuserve.com/homepages/hoenicka_markus/ --z1KCTocaUN Content-Type: text/plain; charset=us-ascii -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com --z1KCTocaUN--