netutils use of socket descriptor

Thomas Guyot-Sionnest dermoth at aei.ca
Mon Jun 15 20:27:39 CEST 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 13/06/09 08:17 AM, Hiren Patel wrote:
> wondering if this is a valid change.
> attached. thanks.

Good catch, though it looks like it will have no effect whatsoever.

According to socket(2):
  On success, a file descriptor for  the  new  socket  is  returned. On
  error, -1 is returned, and errno is set appropriately.

In other words if sd is not <0 (which returns an error immediately) the
condition will always succeed (just like when testing the pointer) and
there is no need to walk further the r list.

If you want to connect with a given per-address or global timeout, then
you'll have to include most of the rest of the function in the while(r)
loop... unfortunately that will give you a per-ip timeout which is
likely not desired.


A better way of doing this is to send a connect for the next ip in list
every n miliseconds (where n is a small fraction of the timeout, you
could for example take half of the timeout and divide it by the number
of IP), use the first connected socket and clean up the rest.


- --
Thomas
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFKNpKb6dZ+Kt5BchYRAr5kAKDRKewdaQdhHO/zIO3it0rQShcEcgCg/Dbj
4gpQ/7cEuRf17boUA6glazo=
=knMY
-----END PGP SIGNATURE-----

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects




More information about the Developers mailing list