![Anybus CompactCom 40 Common Ethernet Design Manual Download Page 71](http://html1.mh-extra.com/html/anybus/compactcom-40-common-ethernet/compactcom-40-common-ethernet_design-manual_2948756071.webp)
69 (104)
Command Details: Shutdown
Category
Extended
Details
Command Code
11h
Valid for:
Instance
Description
This command closes a TCP-connection using the FIN-flag. Note that the response does not indicate if the
connection actually shut down, which means that this command cannot be used to poll non-blocking sockets,
nor will it block for blocking sockets.
•
Command Details
Field
Contents
CmdExt[0]
(reserved, set to zero)
CmdExt[1]
Value:
00h
01h
02h
Mode:
Shutdown receive channel
Shutdown send channel
Shutdown both receive- and send channel
•
Response Details
(no data)
The recommended sequence to gracefully shut down a TCP connection is described below.
Application initiates shutdown:
1.
Send shutdown with CmdExt[1] set to 01h. This will send FIN-flag to host shutting down the send chan-
nel, note that the receive channel will still be operational.
2.
Receive data on socket until error message Object specific error (EPIPE (13)) is received, indicating that
the host closed the receive channel. If host does not close the receive channel use a timeout and prog-
ress to step 3.
3.
Delete the socket instance. If step 2 timed out, RST-flag will be sent to terminate the socket.
Application initiates shutdown:
1.
Receive data on socket, if zero bytes received it indicates that the host closed the receive channel of the
socket.
2.
Try to send any unsent data to the host.
3.
Send shutdown with CmdExt[1] set to 01h. This will send FIN-flag to host shutting down the receive
channel.
4.
Delete the socket instance.
Anybus
®
CompactCom
™
40 Common Ethernet Design Guide
HMSI-27–269 2.1