Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming.threads > #615

Re: Non-blocking socket operations

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Rainer Weikusat <rweikusat@mssgmbh.com>
Newsgroups comp.unix.programmer, comp.programming.threads
Subject Re: Non-blocking socket operations
Date Mon, 26 Sep 2011 19:10:27 +0100
Lines 37
Message-ID <87bou718fg.fsf@sapphire.mobileactivedefense.com> (permalink)
References <j5p1dq$8i9$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Trace individual.net sNRyomSkHo+l+IEW/ObYRAhNViLfHtwl2IbkNGgZd8u0xajNw=
Cancel-Lock sha1:92HitnHain+7JQzkDY54F/OX+ac= sha1:mQVANo0CCNE968aDtLXL0ZkMPhU=
User-Agent Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)
Xref x330-a1.tempe.blueboxinc.net comp.unix.programmer:1324 comp.programming.threads:615

Cross-posted to 2 groups.

Show key headers only | View raw


ittium <ittium@gmail.com> writes:

[...]

> connect
> -------
> connect on non-blocking socket may either return immediately or with
> EINPROGRESS. In the second case we start a timer and on timer expiry,
> using select, we find out whether connect was successful. fd is marked
> as connected if
>
> 	- socket fd is writable
> 	- writting zero bytes on socket is successful. If not
>
> Issue -  Is this logic portable.

According to the current UNIX(*) standard an attempt to write zero
bytes 'may detect and return errors'. Using getsockopt querying the
option SO_ERROR at level SOL_SOCKET will do so. It is unclear what the
purpose of the timer is supposed to be. The networking stack already
contains logic for that and just waiting until the socket becomes
writable an inspection a possibly available error code should be
sufficient.

[...]

> getaddrinfo
> -----------
> 	getaddrinfo is executed in a thread result is returned in a
> call back and then this thread exit.
>
> Issue- When software is doing lot of DNS lookups, lots of such threads
> will be needed. Is there a better way of doing it.

The simple way would be to use a fixed number of address lookup threads
and some kind of (userspace) queue to distribute lookup requests among
them.

Back to comp.programming.threads | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Non-blocking socket operations ittium <ittium@gmail.com> - 2011-09-26 10:39 +0530
  Re: Non-blocking socket operations Nobody <nobody@nowhere.com> - 2011-09-26 13:02 +0100
  Re: Non-blocking socket operations Rainer Weikusat <rweikusat@mssgmbh.com> - 2011-09-26 19:10 +0100
  Re: Non-blocking socket operations William Ahern <william@wilbur.25thandClement.com> - 2011-09-26 13:44 -0700

csiph-web