Several times in the past, I've run across the need to shut down a single network socket for a program that had several open. The best solution I've come up with is target the particular host it was connected to (that is, the one I want to d/c) and fire up iptables.
I find this solution somewhat clunky, and I really don't like having to do it. Granted, I need this ability very often, it'd nice to have.
So, my question is, is there some system call, or standard tool that I don't know about, that allows me to force-close a network socket? My other attempt would be to just inject a RST with nemesis orso, but I'd rather do it what I would consider a 'proper' way.
Is there anything like this out there? Or is this something the kernel doesn't even really support at this time?
if u create a socket then u
if u create a socket then u will get one fd for socket i mean on number. with that u can close ur socket by close( fd); system call.
No, there aren't any APIs
No, there aren't any APIs for remotely terminating some other process's sockets/file descriptors. You probably thought of this, but you could attach a debugger and steal the file descriptor, but that would be a hack with several caveats. I believe injecting RSTs is a more reliable method.