I would suggest this: * Look at the sockets in /proc/[pid]/fd/*. * Grab the inode numbers of the sockets there. * Look for the sockets with the corresponding inode numbers of the processes descriptors in /proc/net/tcp. * At this point you have a list of sockets for the process. * Use local_address and rem_address in /proc/net/tcp to determine the desired entry. * The st field for that entry is the state of the socket. Regards, Nicholas Dronen P.S. This sort of thing is easy to figure out by doing: $ strace -e trace=open netstat -na >/dev/null On Mon, Jun 25, 2001 at 11:08:03AM -0700, Shirley Ma wrote: > > You can reference netstat utility to get socket states in your own program. > > Shirley Ma > Linux Technology Center Networking Group > > "A journey of a thousand miles must begin with a single step" -- LAO-TZU > > > > Lee Chin <leechinus@yahoo.com> on 06/22/2001 05:49:04 PM > > To: Shirley Ma/Beaverton/IBM@IBMUS > cc: linux-net@vger.kernel.org > Subject: Re: maximum sockets > > > > Hi, > I actually meant in C.. in my program, how do I see > what the state of the socket is > > Thanks > Lee > > --- Shirley Ma <xma@us.ibm.com> wrote: > > > > Do " netstat | grep CLOSE_WAIT " command, find the > > related socket by port > > number. > > > > Shirley Ma > > Linux Technology Center Networking Group > > > > "A journey of a thousand miles must begin with a > > single step" -- LAO-TZU > > > > > > > > Lee Chin <leechinus@yahoo.com> on 06/22/2001 > > 04:18:52 PM > > > > To: Shirley Ma/Beaverton/IBM@IBMUS > > cc: linux-net@vger.kernel.org > > Subject: Re: maximum sockets > > > > > > > > How do I tell a socket is stuck in CLOSE_WAIT state? > > > > Thanks > > Lee > > --- Shirley Ma <xma@us.ibm.com> wrote: > > > > > > Run "ulimit -a " command, it will display the open > > > files in your system. > > > Then run "ulimit -n 4000", it will change the open > > > files to 4000. > > > > > > Thanks > > > Shirley Ma > > > > > > Linux Technology Center Networking Group > > > 15450 SW Koll Parkway > > > Beaverton, OR 97006-6063 > > > Phone: (503) 578-7638 > > > FAX: (503) 578-3228 > > > > > > > > > > > > Lee Chin <leechinus@yahoo.com>@vger.kernel.org on > > > 05/19/2001 06:28:43 PM > > > > > > Sent by: linux-net-owner@vger.kernel.org > > > > > > > > > To: Shirley Ma/Beaverton/IBM@IBMUS > > > cc: linux-net@vger.kernel.org > > > Subject: Re: maximum sockets > > > > > > > > > > > > Hi, > > > I am running my process as root. When I do a > > ulimit > > > it says "unlimited" > > > > > > However when I run my program, after 1400 (or so) > > > sockets open, I get a "too many fiule open error" > > > when > > > I try to accept a new socket connection or create > > a > > > new outbound connection. > > > > > > Please advise > > > > > > Thanks > > > Lee > > > --- Shirley Ma <xma@us.ibm.com> wrote: > > > > > > > > There is limitation of max open files per > > process > > > be > > > > default it is 1024. > > > > You can change this value by ulimit -n. There is > > > > also a max files open in > > > > the system 8192, you can also change this value > > by > > > > "sysctl -w > > > > fs.file-max=8192. > > > > > > > > > > > > Thanks > > > > Shirley Ma > > > > > > > > Linux Technology Center Networking Group > > > > 15450 SW Koll Parkway > > > > Beaverton, OR 97006-6063 > > > > Phone: (503) 578-7638 > > > > FAX: (503) 578-3228 > > > > > > > > > > > > > > > > Lee Chin <leechinus@yahoo.com>@vger.kernel.org > > on > > > > 05/16/2001 04:11:59 PM > > > > > > > > Sent by: linux-net-owner@vger.kernel.org > > > > > > > > > > > > To: linux-net@vger.kernel.org > > > > cc: > > > > Subject: maximum sockets > > > > > > > > > > > > > > > > Hi, > > > > Is there a limitation on the number of sockets > > my > > > > program can have open? At around 1300 sockets > > > open, > > > > I > > > > get a "too many files open" error. > > > > > > > > Thanks > > > > Lee > > > > > > > > > > __________________________________________________ > > > > Do You Yahoo!? > > > > Yahoo! Auctions - buy the things you want at > > great > > > > prices > > > > http://auctions.yahoo.com/ > > > > - > > > > : send the line > > > > "unsubscribe linux-net" in > > > > the body of a message to > > majordomo@vger.kernel.org > > > > > > > > > > > > > > > > > > > > > __________________________________________________ > > > Do You Yahoo!? > > > Yahoo! Auctions - buy the things you want at great > > > prices > > > http://auctions.yahoo.com/ > > > - > > > : send the line > > > "unsubscribe linux-net" in > > > the body of a message to majordomo@vger.kernel.org > > > > > > > > > > > > > > > __________________________________________________ > > Do You Yahoo!? > > Get personalized email addresses from Yahoo! Mail > > http://personal.mail.yahoo.com/ > > > > > > > > > __________________________________________________ > Do You Yahoo!? > Get personalized email addresses from Yahoo! Mail > http://personal.mail.yahoo.com/ > > > > - > : send the line "unsubscribe linux-net" in > the body of a message to majordomo@vger.kernel.org - : send the line "unsubscribe linux-net" in the body of a message to majordomo@vger.kernel.org