Sponsored Content
Full Discussion: Unix Socket
Top Forums Programming Unix Socket Post 302565771 by DreamWarrior on Tuesday 18th of October 2011 05:31:02 PM
Old 10-18-2011
Quote:
Originally Posted by Corona688
select() is there to tell you whether things will block or not, whic makes O_NONBLOCK rather redundant. Probably shouldn't use both.
???

You have to put a socket into non-blocking mode to use select/poll. Well, you don't have to, but there have been bugs reported against some implementations that will cause select/poll to behave unpredictably or incorrectly if a blocking socket is placed into the select/poll list. So, you should use both.

Further, select is advisory only. So, even if select tells you that the socket "won't block" because it is readable/writeable, when you turn around and try to read/write more than is available in the appropriate TCP buffer from/to a blocking socket the call will still block. Select just tells you the socket can be read/written from/to, more accurately (for most implementations) it tells you the watermark set on the socket has been met for the operation. Typically that watermark is set at 1 byte for both read and write. Therefore, once a single byte can be read or written to the socket select/poll says it's readable/writable. So, if you immediately tried to read/write more than a byte, it's certainly possible (again if you didn't use O_NONBLOCK) that the call could block.

That said, in most implementations these watermarks can be changed. Some developers have tried using that to make their applications more efficient. For example, if knew a header (of size sz) needed to be read at the moment, I could set the read low water mark to sz. Select wouldn't say the socket was readable until sz bytes were available. Of course, this assumes there is enough TCP send/receive space to hold that. Unfortunately, I read some report that said their attempts to improve efficiency this way were thwarted by the fact that constantly changing the watermark was not efficient enough to be worth it.

Anyway...that's a little off topic, but the point is, I don't know how you can say you shouldn't use both. You should, and in some cases, have to use both.
These 2 Users Gave Thanks to DreamWarrior For This Post:
 

10 More Discussions You Might Find Interesting

1. Programming

How can I program socket in unix?

Excuse me . I'm a beginner . In windows , MFC can be used , but how to do in Unix ? And does unix support c++like VC++ ? How can I get developing tools in Unix ? (7 Replies)
Discussion started by: sanjohn
7 Replies

2. HP-UX

Problem in HP-Unix while writing into socket

Our system is having a server and multiple clients. We are monitoring the client FDs using select() system call in HP-UX. After establishing connection-using socket with the remote client, before start sending the data we are checking the status of socket using select( ) call. For first 16... (0 Replies)
Discussion started by: AshokG
0 Replies

3. UNIX for Advanced & Expert Users

Unix: socket & Co

Hello, I need help to replace the ................. of client.c that request the server implemented by server.c ------------------ Listing 1 - server.c /* Inclusion des différentes librairies nécessaires */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> ... (0 Replies)
Discussion started by: bounkolh
0 Replies

4. UNIX for Dummies Questions & Answers

Checking who is listening on a Unix Domain Socket

Hi all, I'm writing a kernel module and part of it involves controlling IPCs between processes. My problem is when a process tries to connect to a Unix domain socket, the only identifying information of the socket it supplies (that I can see, anyway) is the special pathname of the socket. From... (0 Replies)
Discussion started by: blank87
0 Replies

5. UNIX for Dummies Questions & Answers

Socket Handling Differences Between Linux & Unix?

Sorry if this is a stupid question! I have been developing a Java application that I am deploying on both Unix and Linux servers, which uses lots of socket handling. When the server side connection is dropped by the server un-gracefully I have been seeing close_waits and null connections. ... (0 Replies)
Discussion started by: Vinnie
0 Replies

6. UNIX for Advanced & Expert Users

connect problem for sctp socket (ipv6 socket) - Runtime fail Invalid Arguments

Hi, I was porting ipv4 application to ipv6; i was done with TCP transports. Now i am facing problem with SCTp transport at runtime. To test SCTP transport I am using following server and client socket programs. Server program runs fine, but client program fails giving Invalid Arguments for... (0 Replies)
Discussion started by: chandrutiptur
0 Replies

7. IP Networking

Help with Unix socket programing

hi I am strucked in a client server program client need to login to server client logins if only username and password are correct i have written a program username is stored as file and password is smilar to username whic is stored in that file when server asks for username... (2 Replies)
Discussion started by: karthik1238
2 Replies

8. UNIX for Advanced & Expert Users

C socket program on UNIX

Write a C socket program on UNIX where a TCP client sends/reads a time in decimal 24 hours format to the server and the server echoes the seconds, minutes, and hours in the time. Example: Client sends 18.78 hours and the server displays 18 hours, 46 minutes and 48 seconds. (1 Reply)
Discussion started by: adi_always4u143
1 Replies

9. Programming

unix socket programming

Hi all, my name is anjali, working as an intern, doing masters i have an assignment from my school, which i am not able to solve, can someone please help me in finding the solution for this problem thanking you in advance....lol Write a C socket program on UNIX where a TCP client... (1 Reply)
Discussion started by: anjali.symantec
1 Replies

10. IP Networking

Clarification - Setting socket options at the same time when socket is listening

I need clarification on whether it is okay to set socket options on a listening socket simultaneously when it is being used in an accept() call? Following is the scenario:- -- Task 1 - is executing in a loop - polling a listen socket, lets call it 'fd', (whose file descriptor is global)... (2 Replies)
Discussion started by: jake24
2 Replies
LIRCRCD(1)								FSF								LIRCRCD(1)

NAME
lircrcd - daemon to handle consistent .lircrc state among client applications SYNOPSIS
lircrcd [options] config-file DESCRIPTION
lircrcd reads the given .lircrc config file and synchronises the mode that the LIRC clients using this config file (irexec(1), irxevent(1) , etc.) are in. Using lircrcd has to be explicitly enabled in the config file by adding the following line at the beginning of the file: #! lircrcd -h --help display this message -v --version display version -p --permission=mode file permissions for socket -o --output=socket output socket filename OPTIONS
-p, --premission=mode The --permission option gives the file permission of the Unix domain socket lircrcd creates on startup in octal representation. Read the documentation for chmod for further details. If no --permission option is given when the socket is created the default is to give only the user owning the file read and write permissions (0600 in octal representation). -o, --output=socket With the --output option you can select the Unix domain socket, which lircrcd will create. The default is to append a "d" character to the config filename given. SEE ALSO
The documentation for lirc is maintained as html pages. They are located under html/ in the documentation directory. lircrcd 0.8.7pre1 May 2010 LIRCRCD(1)
All times are GMT -4. The time now is 10:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy