> Attempt to gracefully close the socket. If there is still some
> data waiting in the buffers it will try to send it. ***Do not use
> Close from within any TWSocket events, instead use CloseDelayed.***

You even have to call Shutdown(1) to really gracefully close the socket.
Calling Shutdown will send the close request to the other side which in turn
will close his side and then you receive the OnSessionClosed event. Be aware
that if the remote side is hung, you may never receive the real close. You
then must call Abort after a timeout of your choice.

Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
The author for the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be

----- Original Message ----- 
From: "Jack" <[EMAIL PROTECTED]>
To: "ICS support mailing" <twsocket@elists.org>
Sent: Thursday, May 19, 2005 4:53 PM
Subject: Re[4]: [twsocket] Receive result of the first ReceiveStr() call
twice


> Francois, thanks! This fixed the problem! It's actually in the FAQ:
>
> - CloseDelayed
>
> Is in most cases the preferred way. It will post a message to
> itself to close the TWSocket. This means that the socket closure
> is done outside the code that calls the CloseDelayed, meaning a
> while later. The message handler will call Close.
>
> - Close
>
> Attempt to gracefully close the socket. If there is still some
> data waiting in the buffers it will try to send it. ***Do not use
> Close from within any TWSocket events, instead use CloseDelayed.***
>
>
> Thursday, May 19, 2005, 2:46:47 AM, you wrote:
>
> FP> Use CloseDelayed instead of Close.
>
> >> Hello Wilfried,
> >>
> >> Sure. Below is my event handler code. Hope I'm doing something
> >> wrong, otherwise, it's really strange. TProxyChecker is the owner
> >> object of the TProxySocket object array. TProxySocket is derived
> >> from TWSocket.
> >>
> >> procedure TProxyChecker.WSocketDataAvailable(Sender: TObject; ErrCode:
Word);
> >> var s: String;
> >> begin
> >>   if ErrCode = 0 then
> >>     with TProxySocket(Sender) do
> >>     begin
> >>       s := ReceiveStr();
> >>       Log(s);
> >>       Close();
> >>     end;
> >> end;
> >>
> >> The destination server is a commercial http proxy server.
> >> I tried using #13#10 and #13#10#13#10, I different strings
> >> read back from ReceiveStr. But the second string includes
> >> the first string in both cases. So it shouldn't be the server
> >> sending the string twice.
> >>
> >> BTW, I'm using the latest ICS.
> >>
> >> -- 
> >> Best regards,
> >> Jack
> >>
> >> Wednesday, May 18, 2005, 3:31:32 PM, you wrote:
> >>
> >> WM> Hello Jack,
> >>
> >> WM> Can you show your OnDataAvailable handler ?
> >> WM> Eventually download SocketSpy from 'user made' page and 'hang' it
> >> WM> between client and server. Then you see exacly what is sent by
server.
> >>
> >> WM> ---
> >> WM> Rgds, Wilfried
> >> WM> http://www.mestdagh.biz
> >>
> >> WM> Wednesday, May 18, 2005, 20:48, Jack wrote:
> >>
> >> >> Hello Francois and all,
> >>
> >> >> I'm using a TWSocket client in LineMode with LineEnd set to #13#10.
> >> >> I connect to a HTTP proxy server using CONNECT command. I then get
> >> >> a reply back from the HTTP proxy from ReceiveStr()
> >>
> >> >> Things look OK except that I am receiving the data from the first
> >> >> ReceiveStr() call twice. I get two WSocketDataAvailable messages for
> >> >> 3 lines in the HTTP response:
> >>
> >> >>   Line 1: HTTP/1.0 200 Connection established
> >> >>   Line 2: Proxy-agent: Proxy+ 3.00
> >> >>   Line 3: (Blank line)
> >>
> >> >> However, I'm getting the first ReceiveStr() result twice, see below:
> >> >> I'm getting "HTTP/1.0 200 Connection established" twice:
> >>
> >> >> 5/18/2005 2:36:43 PM WSocketDataAvailable idx=0 addr=127.0.0.1:4480
ErrCode=0
> >> >> 5/18/2005 2:36:43 PM HTTP/1.0 200 Connection established
> >> >> 5/18/2005 2:36:43 PM
> >> >> 5/18/2005 2:36:43 PM
> >> >> 5/18/2005 2:36:43 PM WSocketDataAvailable idx=0 addr=127.0.0.1:4480
ErrCode=0
> >> >> 5/18/2005 2:36:43 PM HTTP/1.0 200 Connection established
> >> >> Proxy-agent: Proxy+ 3.00
> >>
> >>
> >> >> I then changed LineEnd to #13#10#13#10, I still get the result of
> >> >> the first ReceiveStr() twice, this time the result is two lines:
> >>
> >> >>   HTTP/1.0 200 Connection established
> >> >>   Proxy-agent: Proxy+ 3.00
> >> >>   (Blank line)
> >>
> >> >> 5/18/2005 2:40:11 PM WSocketDataAvailable idx=0 addr=127.0.0.1:4480
ErrCode=0
> >> >> 5/18/2005 2:40:11 PM HTTP/1.0 200 Connection established
> >> >> Proxy-agent: Proxy+ 3.00
> >>
> >>
> >> >> 5/18/2005 2:40:11 PM
> >> >> 5/18/2005 2:40:11 PM
> >> >> 5/18/2005 2:40:11 PM WSocketDataAvailable idx=0 addr=127.0.0.1:4480
ErrCode=0
> >> >> 5/18/2005 2:40:11 PM HTTP/1.0 200 Connection established
> >> >> Proxy-agent: Proxy+ 3.00
> >>
> >>
> >> >> It seems that, somehow the first ReceiveStr() didn't remove the data
> >> >> from the buffer. Or am I missing anything?
> >>
> >>
> >> >> -- 
> >> >> Best regards,
> >> >> Jack
> >>
> >>
> >>
> >>
> >>
> >>
> >> -- 
> >> To unsubscribe or change your settings for TWSocket mailing list
> >> please goto http://www.elists.org/mailman/listinfo/twsocket
> >> Visit our website at http://www.overbyte.be
> >>
>
>
>
> -- 
> To unsubscribe or change your settings for TWSocket mailing list
> please goto http://www.elists.org/mailman/listinfo/twsocket
> Visit our website at http://www.overbyte.be
>


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to