-
Notifications
You must be signed in to change notification settings - Fork 15
Socket shutdown
yfakariya edited this page May 2, 2012
·
1 revision
Socket shutdown is initiated from client or server on following reason:
- Client application will be exit, so the application initiates graceful shutdown. This causes graceful shutdown.
- Client application was exit without initiating shutdown or crushed, so the connection is closed. This causes rude shutdown.
- Server application will be exit, so the application initiates graceful shutdown. This causes graceful shutdown.
- Server application was exit without initiating shutdown or crushded, so the connection is closed. This causes rude shutdown.
If socket shutdown is initiated rudely, the error (like "Connection Reset" error) is occurred in opposite side. If socket shutdown is initiated gracefully, following events will be occurred.
Client behavior is following:
-
ClientTransport.BeginShutdown
is called, then the transport go to 'is in shutdown' state. SubsequentSend
invocation will be fail. -
ClientTransport
initiates sending shutdown. For TCP/IP, underlying socket API sendsFIN
packet. -
ClientTransport
cancels pending sending operations. -
ClientTransport
invokes all asynchronous callbacks with cancellation error. -
ClientTransport
wait for the server also shutdown sending with processing pending response. -
ClientTransport
receives server shutdown packet, initiates receiving shutdown. -
ClientTransport
raisesShutdownCompleted
event.
Server behavior is following:
-
ServerTransport
receives client shutdown notification. -
ServerTransport
raisesClientShutdown
event. -
ServerTransport
initiates receiving shutdown. -
ServerTransport
processes remaining pending request as possible, and discards requests/notifications which are not able to dispatch. -
ServerTransport
responds all responses to the client. - When the count of pending request reach to zero,
ServerTransport
initiates sending shutdown. For TCP/IP, underlying socket API sendsFIN
packet. -
ServerTransport
raisesShutdownCompleted
event.
Server behavior is following:
-
ServerTransport.BeginShutdown
is called. -
ServerTransport
initiates receiving shutdown. -
ServerTransport
processes remaining pending request as possible, and discards requests/notifications which are not able to dispatch. -
ServerTransport
responds all responses to the client. - When the count of pending request reach to zero,
ServerTransport
initiates sending shutdown. For TCP/IP, underlying socket API sendsFIN
Client behavior is following:
-
ClientTransport
receives server shutdown notification. -
ClientTransport
raisesServerShutdown
event. -
ClientTransport
initiates receiving shutdown. -
ClientTransport
cancels pending sending operations. -
ClientTransport
invokes all asynchronous callbacks with cancellation error. -
ClientTransport
initiates sending shutdown. For TCP/IP, underlying socket API sendsFIN
packet. -
ClientTransport
raisesShutdownCompleted
event.