03-20-2010
Sockets select() question
Hello everyone. I have a question regarding select() function. Imagine i had passed a fd_set* as the readfds parameter. Can i add some fd to the fd_set, using FD_SET, while the thread is blocked in the select call(obviously from another thread), and will that select call monitor those fd, even if they where added after the select call?
Thanks in advance!
10 More Discussions You Might Find Interesting
1. Programming
Hi !
I had a verry simple question to ask...
In unix when we create pipes.. the unnamed pipes that is...
is there any way to access those pipes outside the code ?
Another thing.. do sockets have an entry in the inode table ?
TIA,
Devyani. (1 Reply)
Discussion started by: devy8
1 Replies
2. Programming
I am looking for a way to have a program listen on a port (example: 8000) for communication I will be sending via that port to it(Linux Kernel machine). Once it recieves an appropiate command I need it to run a .bat file in linux.
I know what I need to do but I am running into a few problems:... (8 Replies)
Discussion started by: bigB8210
8 Replies
3. Programming
I'm new to sockets programming and I have a few questions:
Is the a maximum limit that you can use for the send and receive buffers via a call to setsockopt()? Does it differ on different OSs? If it does, how do I find out the max limit?
What is the advantage to setting the buffers to be... (1 Reply)
Discussion started by: jalburger
1 Replies
4. Programming
I apologize if this seems like a repeat post, but I never got a clear answer (this isn't a criticism, it's possible I'm not being clear enough)....I'm attempting to enlarge the socket buffers for a udg socket, but it seems that no matter how large I attempt to set the buffer with
setsockopt( )
... (3 Replies)
Discussion started by: jalburger
3 Replies
5. UNIX for Dummies Questions & Answers
how do i mointor how many sockets are opened from a particular foriegn address? (2 Replies)
Discussion started by: kirpond
2 Replies
6. Solaris
Is there a way to see what sockets are in use? The developers here are getting some defunct processes and they would like to get a socket list.
This is on a Solaris 8 machine.
Thanks! (1 Reply)
Discussion started by: kjbaumann
1 Replies
7. Programming
anyone and teach me how to save standard output to a file in a client/server socket. I know how to read them to the screen but i'm not quite sure how to save them to a file.
my read to screen file code:
memset(line, 0x0, LINE_ARRAY_SIZE);
while (recv(connectSocket, line, MAX_MSG, 0) >... (1 Reply)
Discussion started by: crunchyuser
1 Replies
8. Programming
Hey guys,
Is it possible to have a worker thread send data out a TCP connection while another thread is waiting using using select() on that same connection?
If not, then what is the correct way to maintain a connection, react to incoming data, and send data over a TCP connection?
Thanks... (16 Replies)
Discussion started by: scubanarc
16 Replies
9. Shell Programming and Scripting
I am creating a Select menu with a few options and I would like to create a "better" looking interface than just this:
1) Option 1
2) Option 2
3) Option 3
Instead, I would like something like this:
***********
* Cool Script *
* 1) Option 1 *
* 2) Option 2 *
* 3) Option 3 *... (2 Replies)
Discussion started by: chipblah84
2 Replies
10. IP Networking
Hi -
I've written an app that, among other things, accepts a telnet connection (made via the "telnet" command from a terminal) and converses with it. I'd like to make this work so that only one client at a time can connect. Currently, when a second user tries to connect, the incoming messages... (2 Replies)
Discussion started by: mzimmers
2 Replies
LEARN ABOUT POSIX
sys_select.h
<sys/select.h>(P) POSIX Programmer's Manual <sys/select.h>(P)
NAME
sys/select.h - select types
SYNOPSIS
#include <sys/select.h>
DESCRIPTION
The <sys/select.h> header shall define the timeval structure that includes at least the following members:
time_t tv_sec Seconds.
suseconds_t tv_usec Microseconds.
The time_t and suseconds_t types shall be defined as described in <sys/types.h> .
The sigset_t type shall be defined as described in <signal.h> .
The timespec structure shall be defined as described in <time.h> .
The <sys/select.h> header shall define the fd_set type as a structure.
Each of the following may be declared as a function, or defined as a macro, or both:
void FD_CLR(int fd, fd_set *fdset)
Clears the bit for the file descriptor fd in the file descriptor set fdset.
int FD_ISSET(int fd, fd_set *fdset)
Returns a non-zero value if the bit for the file descriptor fd is set in the file descriptor set by fdset, and 0 otherwise.
void FD_SET(int fd, fd_set *fdset)
Sets the bit for the file descriptor fd in the file descriptor set fdset.
void FD_ZERO(fd_set *fdset)
Initializes the file descriptor set fdset to have zero bits for all file descriptors.
If implemented as macros, these may evaluate their arguments more than once, so applications should ensure that the arguments they supply
are never expressions with side effects.
The following shall be defined as a macro:
FD_SETSIZE
Maximum number of file descriptors in an fd_set structure.
The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided.
int pselect(int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
const struct timespec *restrict, const sigset_t *restrict);
int select(int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
struct timeval *restrict);
Inclusion of the <sys/select.h> header may make visible all symbols from the headers <signal.h>, <sys/time.h>, and <time.h>.
The following sections are informative.
APPLICATION USAGE
None.
RATIONALE
None.
FUTURE DIRECTIONS
None.
SEE ALSO
<signal.h> , <sys/time.h> , <sys/types.h> , <time.h> , the System Interfaces volume of IEEE Std 1003.1-2001, pselect(), select()
COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technol-
ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE
and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained
online at http://www.opengroup.org/unix/online.html .
IEEE
/The Open Group 2003 <sys/select.h>(P)