2

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?

XTF
  • 1,091
  • 1
  • 13
  • 31

1 Answers1

3

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));
selbie
  • 100,020
  • 15
  • 103
  • 173