From: Francis Cianfrocca Date: 2006-05-09T10:11:53+09:00 Subject: Re: Considering Ruby For a Networking Application ------=_Part_47035_29686373.1147137111006 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline One more thing, what happens if you run this program on Windows on a network? You have an intra-process localhost connection and the kernel may be behaving differently in this case, particularly as regards the buffer usage that would interact with nonblocking i/o. Thanks for correcting me on the wrapper in win32.c. I have to say, it's a strange design choice. To me it would have made more sense to wrap both behind a "setnonblocking" method. Also, that source file is interesting, it looks like the Ruby folks borrowed it. On 5/8/06, Bill Kelly wrote: > > > From: "Francis Cianfrocca" > > > > From what you said, this code doesn't do what you think it should do: > > > > # hmm, io/nonblock refuses to work on windows because > > # of missing GETFL :( Just fake it... > > if RUBY_PLATFORM =3D~ /mswin32/ > > class IO > > def nonblock=3D(nb) > > fcntl(Fcntl::F_SETFL, nb ? Fcntl::O_NONBLOCK : 0) > > end > > end > > end > > > > That's because on Windows, this isn't the way to set sockets > nonblocking. > > Microsoft reinvented a lot of wheels in Windows, and this is one of 'em= . > Try > > this C code instead (I'll leave it to you to turn it into Ruby): > > > > unsigned long one =3D 1; > > ioctlsocket (the_socket_descriptor, FIONBIO, &one); > > Right, except that in win32/win32.c, ruby corrects microsoft's > misfeatures for us, by making fcntl() on win32-ruby shunt to > ioctlsocket behind the scenes: > > int > fcntl(int fd, int cmd, ...) > { > //[...] > > if (arg & O_NONBLOCK) { > ioctlArg =3D 1; > } > else { > ioctlArg =3D 0; > } > RUBY_CRITICAL({ > ret =3D ioctlsocket(sock, FIONBIO, &ioctlArg); > if (ret =3D=3D -1) { > errno =3D map_errno(WSAGetLastError()); > } > }); > > > Regards, > > Bill > > > > ------=_Part_47035_29686373.1147137111006--