CodePudding user response:
Net. Conn did not provide such interfaces to directly determine theBy using the abnormal capture mode
CodePudding user response:
Normal client close connections, you use err. EOF judgment, the server to get data length is zero, also think is closed, the server reads the timeout, also want to shut down, the client abnormal exit, you use theErrStr: err...=Error ()
If strings. The Contains (errStr, "An existing connection was forcibly closed by the remote host") | |
Strings. The Contains (errStr, "An established connection was aborted by the software in your host machine") | |
Strings. The Contains (errStr, "connection reset by peer") {
Break
}
This method although soil, good compatibility, Windows, Unix are available,
CodePudding user response:
TCP is operating common patterns, you when the connection is normal, a read or write, if the connection is disconnected, will return an error at this time,