[prev in list] [next in list] [prev in thread] [next in thread]
List: sbcl-devel
Subject: Re: [Sbcl-devel] Possible fix for read-char-no-hang on Win32
From: Kalyanov Dmitry <kalyanov.dmitry () gmail ! com>
Date: 2010-10-01 18:24:57
Message-ID: 1285957497.6008.1.camel () dvk-laptop ! localdomain
[Download RAW message or body]
On Thu, 2010-09-30 at 12:23 +0300, Nikodemus Siivola wrote:
> On 11 July 2010 11:04, Kalyanov Dmitry <kalyanov.dmitry@gmail.com> wrote:
>
> > I've found out that it's possible to peek the input buffer size of a
> > Winsock socket by calling WSAIoctl(FIONREAD). I've tried to use it
> > for checking for available input on a socket and it seems to work.
> >
> > Using WSAIoctl works fine when Winsock hadn't been initialized by
> > call to WSAStartup (WSAGetLastError returns WSANOTINITIALISED) and
> > when handle is not a socket (WSAGetLastError returns WSAENOTSOCK).
> > Also this doesn't modify socket in any way while WSAEventSelect sets
> > socket to non-blocking mode and changes its notification event.
> >
> > Are there any problems with this approach?
>
> I'm don't know nearly enough about Windows to have an educated view on
> this, but looking at
> http://msdn.microsoft.com/en-us/library/ms741621%28v=vs.85%29.aspx it
> seems reasonable enough.
>
> If this makes things better for you and others on Windows, I think
> merging it sounds reasonable enough unless those with more Win-fu have
> objections. (I didn't review the patch properly yet, though.)
>
> I would, however, like a test-case that passes with this but doesn't without.
The test case can be found at
http://article.gmane.org/gmane.lisp.slime.devel/7991 and I'm attaching a
modified version of it that can be run from shell. Unfortunarely I don't
know how to convert it to pure lisp code. This test tries to read from a
connected socket when no data is available and read-char-no-hang should
return NIL while instead it blocks until first byte is available.
["test-win32-socket-r-c-n-h.sh" (application/x-shellscript)]
#!/bin/sh
prg=`cat <<EOF
(require '#:sb-bsd-sockets)
(use-package '#:sb-bsd-sockets)
(let ((socket (make-inet-socket :stream :tcp)))
(socket-bind socket #(0 0 0 0) 12345)
(socket-listen socket 5)
(let* ((accepted (socket-accept socket))
(stream-in (socket-make-stream accepted :input t))
(char (read-char-no-hang stream-in)))
(if (null char)
(format t "OK, got NIL as expected~%")
(format t "Bad, I've got an input: ~S~%" char))))
(quit)
EOF
`
echo "$prg" | sh run-sbcl.sh --noinform --noprint --disable-debugger &
sleep 5
(echo qwerty; sleep 1) | telnet localhost 12345 >/dev/null 2>/dev/null
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Sbcl-devel mailing list
Sbcl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sbcl-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic