Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #12354
| From | 88888 Dihedral <dihedral88888@googlemail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: Getting the status of a socket through code |
| Date | 2011-12-11 09:46 -0800 |
| Organization | http://groups.google.com |
| Message-ID | <23346451.1985.1323625598083.JavaMail.geo-discussion-forums@prmw6> (permalink) |
| References | <6babe985-31c8-48a7-807c-aebc1fd9c242@i8g2000vbh.googlegroups.com> <LqGdnf6bufzrXHnTnZ2dnUVZ8gCdnZ2d@giganews.com> <1917565489345315192.614698troplin-bluewin.ch@news.aioe.org> |
On Monday, December 12, 2011 1:15:07 AM UTC+8, Tobias Müller wrote: > Leigh Johnston <le...@i42.co.uk> wrote: > > On 11/12/2011 14:41, oshaer wrote: > >> Hi Everybody > >> > >> > >> I need to write a code that forcibly closes connections that are in > >> CLOSE_WAIT status. It should run at a father process and constantly > >> check the forked child processes(servers). I need this code to work on > >> Unix/Linux, thus usage of WINAPI is not possible. > >> > >> My question is: > >> > >> 1) Should I use netstat through code and parse the result to learn > >> which socket is in a CLOSE_WAIT situation? > >> > >> 2) Is there any C++ code that enables me to easily get socket status, > >> given the file descriptor number? > >> > >> 3) If you have any other ideas/recommendations please share. > > > > Off-topic. > > > > HTH. > > > > /Leigh > > Not everyone knows that sockets are platform specific and there is no > standard C++ API. You could at least point that out. > > To the topic, I don't think that it is possible to close connections of a > different process. You can just kill those processes. > But a connection in CLOSE_WAIT just means that the other peer has already > closed the connection. If the child process is implemented correctly, it > just closes those connections and there won't be any zombie connections. > > Tobi This kind of trivial jobs in shell scripts that can be invoked by a C++ program to spawn a process is really boring. In POSIX compatible OSes the standard output can be directed to a file.
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Getting the status of a socket through code oshaer <oshaer@gmail.com> - 2011-12-11 06:41 -0800
Re: Getting the status of a socket through code Leigh Johnston <leigh@i42.co.uk> - 2011-12-11 14:42 +0000
Re: Getting the status of a socket through code Tobias Müller <troplin@bluewin.ch> - 2011-12-11 17:15 +0000
Re: Getting the status of a socket through code 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-11 09:46 -0800
Re: Getting the status of a socket through code Victor Bazarov <v.bazarov@comcast.invalid> - 2011-12-11 10:52 -0500
Re: Getting the status of a socket through code Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-12-11 22:54 +0000
csiph-web