Solved

are linux sockets blocking by default

Posted on 2004-04-21
4
660 Views
Last Modified: 2007-12-19
hi everybody,

i am writing a socket class in linux

i am using write and read to write and read from my socket

i have searched for information on whether a socket is blocking by default.
all i can find is that to make a socket nonblocking set the O_NONBLOCK fllag.

so i am assuming that my read on the socket will block by default.

i need to be sure .

can someone tell me is my read on the socke blocking by default

thank you


0
Comment
Question by:tryonix
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 1

Accepted Solution

by:
ravenscr98 earned 500 total points
ID: 10884261
Yes, sockets in the Unix environment are by default blocking. This applies to Linux sockets, too.

See W. Richard Stevens, "Unix Network Programming, Networking APIs:Sockets and XTI" (Volume 1) for all the details.

0
 
LVL 9

Expert Comment

by:Alf666
ID: 10884316
I confirm. Sockets are blocking. Hence the two calls (one system V and the other one BSD origins) :

- select
- poll

Both these calls allow you to set-up a loop in which you will be waiting for data on a set of sockets (file descriptors in fact).
When returning, they will give you the list of sockets ready for reading, writing, or the ones with pending exceptions.

Using this mechanism, you will be able to handle data only on sockets that  will allow you to act without blocking.

man select

0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 10885612
I third that ... Linux sockets are blocking by default
0
 

Author Comment

by:tryonix
ID: 10910705
raven answered first so the points go to him.

thanks guys
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question