On Tue, 2002-10-22 at 18:33, ken dreger wrote: > >to see if a server is available and if not reports back to the application > >owners via email or whatever. The issue is that when a connection is > >requested and fails Linux seems to try forever to make the connection. They
Wrong there > >claim that it does not work this way on NT and want to scrape the project. > >Since I am a proponent of running Linux on s/390 I would like to see if > >there is a way to correct this from a Linux operating systems view. When you issue a connect the connection attempt will run until a final timeout (long time) or it gets an error back that is a "fatal" error. So if you connect to a box that is up but not running a service pretty rapidly you'll get "connection refused". If the box isnt there it'll try for a long time to be sure. If you don't want that you can either set an alarm() call to go off when the time you want to wait expires, or you can do asynchronous connects and get on with other work until you get told it completed or get bored. Or you could install big brother, mon or similar existing tools that do the job already - at the very least they contain worked examples of connecting with a timeout using the socket API
