+
+/*
+ Abort the connection in such a way that there is no resulting time-wait state.
+ This should be used cautiously but is needed for situations like when the Linux
+ connect() system call manages to connect us to ourselves through the even number
+ port bug.
+
+ This needs a real file desc as there may not yet be a transport block when
+ the connection may need to be aborted. For this reason, the function name is
+ lower case indicating that user programmes are discouraged from using this
+ function directly.
+*/
+extern void siabort_conn( int fd ) {
+ struct linger opt_val; // value passed as option to set call
+
+ opt_val.l_onoff = 1; // MUST set linger on with a zero len timeout
+ opt_val.l_linger = 0;
+
+ setsockopt( fd, SOL_SOCKET, SO_LINGER, &opt_val, sizeof( opt_val ) ); // disable linger to prevent time-wait
+ CLOSE( fd ); // close will now abort and not result in time-wait (do NOT use shutdown() first!)
+}
+
+/*
+ Close the FD and mark the transport block as unusable/closed.
+ Removal of the block from the list is safe only from the siwait
+ thread. If the abort flag is set in the transport block, then the
+ connection is aborted (reset).
+*/