|
发表于 2006-4-1 22:30:31
|
显示全部楼层
不好意思,又转回来了,我这段时间看书,突然看到了说怎么发rst包来断连接的例子,原理就是先调用setsockopt来设置socket的SO_LINGER选项,再用close关闭socket,这时候TCP就会发RST标志的包来断开连接,而不是FIN,下面是我从man在摘出来的,希望对你来说不太晚,谢谢!
SO_LINGER
Lingers on a close() if data is present. This option controls the action taken when unsent messages queue on a socket and close() is performed. If SO_LINGER is set, the system shall block the process during close() until it can transmit the data or until the time expires. If SO_LINGER is not specified, and close() is issued, the system handles the call in a way that allows the process to continue as quickly as possible. This option takes a linger structure, as defined in the <sys/socket.h> header, to specify the state of the option and linger interval. |
|