Solved

are linux sockets blocking by default

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Debian 3.16.7 3 147
Shell script / command to generate IO / IOPS load 22 354
understanding an rpm spec file 5 60
Problem to telnet 23 165
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 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

18 Experts available now in Live!

Get 1:1 Help Now