Then use Shutdown(2);
Easy to do a testcase for Eric I think. His proposition to use Close() is
not good, CloseDelayed should give a little better but not on a LAN.

I see

The problem is that I can´t wait, because actually this is can be even done on classes destructors such as:

procedure TMyClass.SendTeardown;
begin

 FSocket.Send(@Data[0], Length(Data));

end;

destructor TMyClass.destroy;
begin

 // Send RTSP Teardown message
 SendTeardown;

 // Release the socket
 FSocket.Free;

 inherited Destroy;

end;

So, I can´t wait for events or anything because the socket will be destroyed

In my testing, if I send the data and destroy the socket, the data is actually sent (I can see it on sniffer), even on remote internet hosts

Eric


-----Oorspronkelijk bericht-----
Van: twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org]
Namens Arno Garrels
Verzonden: maandag 1 augustus 2011 16:57
Aan: ICS support mailing
Onderwerp: Re: [twsocket] Socket flushing

Wilfried Mestdagh wrote:
> Hi Eric,
>
>> Socket.Send(@Data[0], Length(Data));
>> Socket.Close;
>
> I think this is better:
>
>> Socket.Send(@Data[0], Length(Data));
>> Socket.Shutdown(1);

This can be dangerous, Shutdown(1) disables sends on the socket,
if not all has been sent yet you'll get a socket exception
on the next internal send attempt. Best practise is to set a
flag and call it from OnDataSent if that flag is set.
Well, you could check WSocket.AllSent however what would
you do if it returnd False?

--
Arno Garrels


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

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

Reply via email to