delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/11/22/01:11:47

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Fri, 22 Nov 2002 01:11:35 -0500 (EST)
From: Wayne Clerke <clerke AT panix DOT com>
To: cygwin AT cygwin DOT com
Subject: bug in cygwin select/socket code(?)
Message-ID: <Pine.NEB.4.44.0211220110240.8604-100000@panix1.panix.com>
MIME-Version: 1.0

The Perl code below creates a non-blocking socket and attempts
to connect it to 127.0.0.1:2 (which should be immediately refused),
The loop shows the socket becomes briefly writable according to
IO::Select. Is there some logic behind this that I'm missing?
It was ok in cygwin v1.3.12-2, but hasn't worked as I expected
in the last two releases (1.3.14-1, 1.3.15-2) .

Here's the output using v1.3.15:
$ perl -w testSockets.pl
sock created: Operation now in progress
Exception (Connection refused)
Writable (Connection refused)
Exception (Connection refused)
Exception (Connection refused)
Exception (Connection refused)
Exception (Connection refused)
Exception (Connection refused)
etc..


Here's the code I used:
use IO::Socket;
use IO::Select;
use strict;
use warnings;

my $sock = IO::Socket::INET->new(Proto=>'tcp') or warn $!;
$sock->blocking(0) or warn $!;
my $addr='127.0.0.1';
my $port=2;
$addr = inet_aton($addr) or warn("inet_aton: $!"), return undef;
my $sockaddr = sockaddr_in($port, $addr) or warn, return undef;
$sock->connect($sockaddr);
if ($sock) {print "sock created: $!\n"}
else {print "Immediate refusal: $!"; exit};
my $sel = IO::Select->new($sock) or warn;
while ($sel->handles) {
  if ($sel->has_exception(.001)) {
    print "Exception (", $!=$sock->sockopt(SO_ERROR), ")\n";
    };
  if ($sel->can_write(.001)) {
    print "Writable (", $!=$sock->sockopt(SO_ERROR), ")\n";
    };
  }

clerke




--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019