Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Mar 2001 13:59:43 -0500
From:      Allen Landsidel <all@biosys.net>
To:        freebsd-stable@freebsd.org
Subject:   RE: Threads vs. blocking sockets
Message-ID:  <4.3.2.7.2.20010329135405.00cab6b8@64.7.7.83>
In-Reply-To: <15043.33567.94042.80830@nomad.yogotech.com>
References:  <F0D64494733BD411BB9A00D0B74A0264021C9C@cpe-24-221-167-196.ca.sprintbbd.net> <F0D64494733BD411BB9A00D0B74A0264021C9C@cpe-24-221-167-196.ca.sprintbbd.net>

next in thread | previous in thread | raw e-mail | index | archive | help
At 11:46 3/29/2001 -0700, Nate Williams wrote:

> > In my experience (on 4 or 5 Unix variants), with a blocking socket either
> > everything is sent or an error (or EOF on recv*) is returned. In fact
> > FreeBSD also does this, unless you link with libc_r instead of libc.
>
>Right, but in threaded systems, there are no 'blocking' sockets.  You
>have to think differently when doing threaded applications.

That is really backwards thinking.

One of the benefits of threading is that you can use blocking sockets 
inside each thread and you get the best of both worlds.

1. Your entire application will not block waiting for data to go in/out.
2. Your code for reading can be much simpler when reading a known/required 
number of bytes from the socket.

The bottom line is you can use blocking sockets in a threaded environment, 
and is probably the only environment where you should.


-------signature file-------
PGP Key Fingerprint:
446B 7718 B219 9F1E 43DD  8E4A 6BE9 D739 CCC5 7FD7

"I don't think [Linux] will be very successful in the long run."
"My experience and some of my friends' experience is that Linux is quite 
unreliable. Microsoft is really unreliable but Linux is worse."
-Ken Thompson, Interview May 1999.

http://www.freebsd.org
FreeBSD - The Power to Serve

http://www.rfnj.org
Radio Free New Jersey - 445 streams - 40kbps @ 22khz Stereo

http://namespace.org -- http://name.space
Resist the ICANN!  Support name.space!


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4.3.2.7.2.20010329135405.00cab6b8>