This is the mail archive of the cygwin@sources.redhat.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: socket read()/write() problem in 1.1.6


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@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@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

sockettest1.tar.gz


-- 
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.Hoenicka@uth.tmc.edu
http://ourworld.compuserve.com/homepages/hoenicka_markus/

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]