Subject: Re: [clisp-list] socket-shutdown and broken http inspect server o n win32

From: "Hoehle, Joerg-Cyril" <[email-masked]>
Date: Wed May 15 08:06:03 2002

Hi,

MS-windoes woes below...

Does anybody know how to tell MS-Windows sockets to gracefully send all the TCP data in the pipe down the road without causing an abort on the other side?

Sam Steingold wrote:
> Gesendet: Dienstag, 16. April 2002 15:58
> missed this.  please try the patch:

> +++ stream.d	Tue Apr 16 09:56:35 2002
> @@ -14119,6 +14115,9 @@
>  #if defined(UNIX_BEOS) || defined(WIN32_NATIVE)
>  local void low_close_socket (object stream, object handle) {
>    begin_system_call();
> + #ifdef WIN32_NATIVE
> +  if (shutdown(TheSocket(handle),SHUT_RDWR)) { SOCK_error(); }
> + #endif
>    if (!( closesocket(TheSocket(handle)) ==0)) { SOCK_error(); }
>    end_system_call();
>  }

I finally went to the Microloft Developer Network and found:
Graceful Shutdown, Linger Options, and Socket Closure
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/ovrvw3_3she.asp
From there, one can navigate to shutdown, closesocket, setsockopt, getsockopt and linger.

It appears from my tiny experiments that:
shutdown(SD_BOTH) is no help
shutdown(SD_SEND) slightly helps: i.e. a local web browser doesn't get an error anymore, but a remote connection only gets part of the output :-( :-(
I.e. part of the HTML trailer and document data is missing, but no error is signaled(!?).

Depending on sys::*inspect-debug* level, the remote side may even see 0 bytes (lower level => less bytes).
The higher the machine load (second clisp executing (LOOP)), the more complete the response.
The result of a remote's Python's urllib.urlopen("http://mymachine.telekom.de:2129/0/:s").read()
can vary between ''(empty) to the full HTML output.
Curiously, Mosaic-2.7b5 output is always truncated towards the end.

To me it seems that doing recv() until EOF before closing is not acceptable (what MS recommends from what I understand). If I say to close, close. Don't read infinite incoming data from port chargen=19 !

Regards,
	Jorg Hohle.

---

From: Sam Steingold <[email-masked]>
Date: Wed May 15 08:36:04 2002

> * In message <[email-masked]>
> * On the subject of "Re: [clisp-list] socket-shutdown and broken http inspect server o n win32"
> * Sent on Wed, 15 May 2002 17:05:32 +0200
> * Honorable "Hoehle, Joerg-Cyril" <[email-masked]> writes:
>
> Sam Steingold wrote:
> shutdown(SD_SEND) slightly helps: i.e. a local web browser doesn't get
> an error anymore, but a remote connection only gets part of the output
> :-( :-(
this is weird since the spec appears to say that SD_BOTH ==> SD_SEND
(as is the case on UNIX)

another thing is that the page you mention suggest Ws2_32.lib while we
are using wsock32.lib.
could you please check whether this matters?

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat7.2 GNU/Linux
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.palestine-central.com/> <http://www.mideasttruth.com/>
Someone has changed your life.  Save? (y/n)