From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16041 invoked by alias); 13 Dec 2007 19:16:13 -0000 Received: (qmail 16032 invoked by uid 22791); 13 Dec 2007 19:16:13 -0000 X-Spam-Check-By: sourceware.org Received: from a.mail.sonic.net (HELO a.mail.sonic.net) (64.142.16.245) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 13 Dec 2007 19:16:03 +0000 Received: from [192.168.1.103] (74-95-195-237-SFBA.hfc.comcastbusiness.net [74.95.195.237] (may be forged)) (authenticated bits=0) by a.mail.sonic.net (8.13.8.Beta0-Sonic/8.13.7) with ESMTP id lBDJG19m031598 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 13 Dec 2007 11:16:01 -0800 Message-ID: <476185AF.5000906@4raccoons.com> Date: Thu, 13 Dec 2007 19:16:00 -0000 From: Wayne Christopher User-Agent: Thunderbird 1.5.0.4 (X11/20060516) MIME-Version: 1.0 To: cygwin@cygwin.com Subject: Re: VM and non-blocking writes References: <47616D31.7090002@4raccoons.com> <20071213175934.GB25863@calimero.vinschen.de> In-Reply-To: <20071213175934.GB25863@calimero.vinschen.de> Content-Type: multipart/mixed; boundary="------------020501020708040208080401" X-IsSubscribed: yes Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com X-SW-Source: 2007-12/txt/msg00324.txt.bz2 --------------020501020708040208080401 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 919 Okay, here's my test program. Compile and run with no arguments, then connect to it from another machine - on a linux box I just did: python import socket s = socket.socket() s.connect(("name-of-windows-box", 12345)) At this point, nbcheck printed: listening to port 12345 on host xp1 (10.1.2.40) got connection from 10.1.2.14 trying to write 100000000 100000000 bytes written When I hit return to exit from nbcheck, it does not actually exit until the remote socket is closed. The VM usage is 100M, which is all the data array that I allocated, so it doesn't look like the write() call allocated anything in my process space. This behavior makes some sense to me, but it's not how I expect it to work (based on the write(2) man page and how it works on linux). It's more like asynchronous write than non-blocking write. Using O_NONBLOCK instead of O_NDELAY doesn't change the behavior. Thanks, Wayne --------------020501020708040208080401 Content-Type: text/x-c++src; name="nbcheck.c" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="nbcheck.c" Content-length: 1785 #include #include #include #include #include #include #include #include main() { int i, fd, fd2, len; struct hostent *hp; struct protoent *pp; char hostname[64]; struct sockaddr_in lAddr, rAddr; char* data; int datalen, datapos; gethostname(hostname, 64); pp = getprotobyname("tcp"); hp = gethostbyname(hostname); assert(pp && hp); fd = socket(AF_INET, SOCK_STREAM, pp->p_proto); assert(fd >= 0); lAddr.sin_family = hp->h_addrtype; memcpy((char *)&lAddr.sin_addr.s_addr, (char *)hp->h_addr, sizeof(lAddr.sin_addr.s_addr)); lAddr.sin_port = htons(12345); i = bind(fd, (struct sockaddr *)&lAddr, sizeof(lAddr)); assert(i >= 0); printf("listening to port %d host %s (%s)\n", ntohs(lAddr.sin_port), hostname, inet_ntoa(lAddr.sin_addr)); i = listen(fd, 5); assert(i >= 0); len = sizeof(rAddr); memset(&rAddr, 0, sizeof(rAddr)); fd2 = accept(fd, (struct sockaddr *)&rAddr, &len); assert(fd2 >= 0); printf("got connection from %s\n", inet_ntoa(rAddr.sin_addr)); i = fcntl(fd2, F_SETFL, O_NDELAY); assert(i >= 0); datalen = (int) 1e8; data = (char *) malloc(datalen); datapos = 0; while (datapos < datalen) { fd_set wfds; FD_ZERO(&wfds); FD_SET(fd2, &wfds); i = select(fd2 + 1, NULL, &wfds, NULL, NULL); assert(i == 1); printf("trying to write %d bytes\n", datalen - datapos); i = write(fd2, data + datapos, datalen - datapos); printf("%d bytes written\n", i); assert(i > 0); datapos += i; assert(datapos <= datalen); } printf("hit return to exit "); getchar(); exit(0); } --------------020501020708040208080401 Content-Type: text/plain; charset=us-ascii Content-length: 218 -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/ --------------020501020708040208080401--