Re: [twsocket] SessionClosed and close/shutdown

2008-08-17 Thread Arno Garrels
JLIST wrote:
 Hello Francois and Arno for the replies.
 
 I read online that on Unix, close() reduce a ref count for
 a socket. The last close() will call shutdown() automatically.
 I'm not sure if the same is true on Windows but I would think
 so because it makes sense and the whole TCP/IP thing starts on
 Unix platforms.

Even though TWSocket.Close also calls ShutDown(1) it actually
does not perform a bidirectional gracefull shutdown, since the 
socket handle may be closed too early. In order to initiate a 
gracefull shutdown after the last byte has been sent call 
shutdown(1) from event OnDataSent. 
For example, SendStr('bye bye') followed by a call to close() 
does not ensure the string is received at the peer. 

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


Re: [twsocket] SessionClosed and close/shutdown

2008-08-16 Thread JLIST
Hello Francois and Arno for the replies.

I read online that on Unix, close() reduce a ref count for
a socket. The last close() will call shutdown() automatically.
I'm not sure if the same is true on Windows but I would think
so because it makes sense and the whole TCP/IP thing starts on
Unix platforms.

Anyway to answer my original question, I made a test and found
out that calling shutdown(0) locally will not trigger a SessionClosed
on remote side. Calling shutdown(1) and shutdown(2) will.

Sunday, August 10, 2008, 10:44:15 PM, you wrote:

 Yes, Shutdown at one side will cause session close at the other side.
 Actaully, Shutdown is the way to gracefully close a connection. Shutdown
 send to the other part a close request. The other part respond with a close.
 The the initiating part call close. This is really the proper way to
 negociate session end.



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