Re: minimal httpd response

From: xbunny (xbunny_at_eidosnet.co.uk)
Date: 02/24/04


Date: Tue, 24 Feb 2004 22:35:29 +0000

Martijn wrote:
>>>>The point is, when I use direct telnet, everything works fine, but
>>>>when I use links, it chokes and tells me the following:
>>>
>>>
>>>> Alert!: Unexpected network read error; connection aborted.
>>>> Can't Access `http://www.xxxxxxx.nl:12000/index.html'
>>>> Alert!: Unable to access document.
>>>>
>>>> lynx: Can't access startfile
>>>>
>>>
>>>I built a toy httpd server once and alot of browsers got PO'd if I
>>>closesocket the connection after sending the headers. They wanted the
>>>socket to linger. Perhaps that is your culprit?
>>>
>>
>>I should qualify that some more, linger is an option you set on the
>>socket, you should still closesocket of course. Forgive me it was a long
>>time ago...
>
>
> Hmmm, I honestly don't know where to look for this one. Check the man pages
> for some of the commands I use (in C), but haven't found anything. Any
> pointers?
>
> Thanks again,
>

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/graceful_shutdown_linger_options_and_socket_closure_2.asp

I know its microsoft but this probably tells it better than I can
(though I guess from the man ref your using unix in which case
closesocket is just close). Basically the problem I had which looks like
yours (ie telnet looks good, browser not happy) was due to not closing
the socket gracefully.
Possibly man setsockopt (look for the section on SO_LINGER), shutdown
and close might help.

Incidentally I found netscape (maybe mozilla now) really handy for
debugging since if you send it back a screwy http response it just
displays it as text!



Relevant Pages

  • Re: minimal httpd response
    ... > I built a toy httpd server once and alot of browsers got PO'd if I ... > closesocket the connection after sending the headers. ... I should qualify that some more, linger is an option you set on the ... socket, you should still closesocket of course. ...
    (comp.programming)
  • Re: Problem receiving Multicast traffic transmitted on receiving inter
    ... when using a separate receiver socket, ... I have a service that both sends and receives multicast frames. ... closesocket; ... sizeof ) == SOCKET_ERROR) ...
    (microsoft.public.windowsce.embedded)
  • Re: socket question: how to use sendto and recvfrom based on the same multicast address
    ... Why don't you just use the same socket for both send and receive? ... multicast address and receive other data from others on the samd ... closesocket; ... if (setsockopt (sockrcv, ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Pending WSARecv do not return when closesocket() is called
    ... Incidentally, does closesocket() return SOCKET_ERROR? ... cmd.exe and the output of cmd.exe is sent back to the client socket. ... All of this is done through 1 IOCP (socket send/read and named pipe ...
    (microsoft.public.win32.programmer.networks)
  • Re: recv() hang
    ... Do you open the socket as OVERLAPPED? ... you call shutdown before closesocket? ... the typical sequence is to detect a broken connection thru failed send / ...
    (microsoft.public.win32.programmer.networks)