Using socket AF_PACKET / SOCK_RAW but tell kernel to not send RST
问题 My question has roughly been discussed here. And the tl;dr solution is to do: iptables -A OUTPUT -p tcp --tcp-flags RST RST -j DROP And you could modify this to only block the port you're actively listening after. But as mentioned in the above question, and here, these are not elegant solutions. Now, I don't really care about the elegance of things. But I do care about learning. So I've dug deep into the Linux source code (mostly interested in Linux based machines for now) and sorted through