Solved

are linux sockets blocking by default

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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 tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

758 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now