Solved

are linux sockets blocking by default

Posted on 2004-04-21
4
664 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

691 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