From: Vincent Cunniffe (vincent at domain diva.ie)
Date: Mon 23 Sep 2002 - 14:24:03 IST
Padraig Brady wrote:
> Vincent Cunniffe wrote:
>> Another interesting question :
>> I want to write a small application to randomly close a socket
>> in another group of named applications, whose pids will be known
>> to the first application.
>> It will not be forked from or associated in anyway linked to the
>> running applications, it just needs to access information about
>> their open TCP sockets and set one of them to 'closed' from
>> Is this possible, has anyone done it, and how?
> First problem is to determine the fds in the processes
> that are sockets. This can be done by walking
> /proc/pid/fd/* and looking for links to "socket:[*]"
Ah, cool. That's the ID of the socket in the global kernel
socket table? Is there an easy way to find out which ones are
connected to what?
> I'm unsure what you mean by closing the socket.
> Do you mean close in the TCP stack to check the
> application handles this correctly, or actually
> closing the fd in the app, so the app will get
> "invalid descriptor" when it tries to use it,
> or do you mean asking the app to close a particular fd?
Closing the socket from outside the application, without it
knowing anything about it, such that it will fail next time
it tries to read/write the fd.
All of this is to simulate network links dropping, if that's
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:19:00 GMT