How to abort 'close' a TCP connection?

1.7k views Asked by At

One normally closes a socket by calling close(). But what if you want to reset / abort the connection (RST packet)? How do you send it from userland?

1

There are 1 answers

0
selbie On BEST ANSWER

If I recall, you set the SO_LINGER option.

struct linger l;
l.l_onoff = 1;
l.l_linger = 0;

setsockopt(sock, SOL_SOCKET, SO_LINGER, &l, sizeof(l));