Wilfried Mestdagh wrote:
> Hello DZ-Jay,
> 
>> Close() ultimately calls Shutdown(1) -- so wouldn't it have the same
>> effect?
> 
> As I recall not exacly the same. Close calls Shutdown(1) and close the
> socket. If you call Shutdown(1) the socket will not be immediatly
> close, but if there is still some data it will be send, and the other
> end will tell it is ready to close when receiving the data. Then the
> socket will be closed by winsock (and OnSessionClosed is then called).
> 
>> I thought the buffer
>> was cleared when read (ReceivedStr property), or am I wrong?
> 
> Yes it is. If OnDataAvailable is called when you call close (with some
> data) then the other end has send some data, or there is somewhere a
> re-entrance problem (somewhere calling the message pump?).

I think the problem is that in TCustomWSocket.InternalClose the message
pump is called. Anyway calling Send() immediately followed be CloseDelay
will most likely (not always) lead to truncated data on the client side.  

Best practice when calling ShutDown(1) from OnDataSent is starting a timer
to detect timeouts when the client should ignore the ShutDown, just in case. 

--
Arno Garrels [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html

-- 
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