Trying to learn Non-Blocking sockets on Solaris 8, please help! ready to fork() it.
From: Chris Ritchey (rethnor_at_yahoo.com)
Date: 05/26/03
- Next message: Bryan Castillo: "Re: "System V IPC is a botch?""
- Previous message: Kurtis D. Rader: "Re: Help : error warning: modified (chunk-) pointer"
- Next in thread: David Schwartz: "Re: Trying to learn Non-Blocking sockets on Solaris 8, please help! ready to fork() it."
- Reply: David Schwartz: "Re: Trying to learn Non-Blocking sockets on Solaris 8, please help! ready to fork() it."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: 26 May 2003 12:26:39 -0700
ok I've tried for the last two days to get some good information on
how to setup a non-blocking socket. I've found limited information on
fcntl and ioctl, but no secure meat on the matter. I have tried just
opening a socket and using the ioctl(...) to set it to non-blocking
however the compiler (gcc and CC) both complain about the function
ioctl not having a prototype.
/* set to non-blocking */
int dummy = 1;
if(ioctl(listenerSD, FIONBIO, (char *) &dummy) < 0)
{
cout << "non-blocking failed." << endl;
return 0;
}
I am including <sys/ioctl.h> and all the necesary sockets libraries.
is there perhaps an option I need to pass to the compiler to link to a
library (-lsocket -lnfs or what ever).
Next Question would be, once(if) I've established a non-blocking
socket how do I check if there are messages/connection, not sure what
to calls them, waiting to be handled. I'm starting to think that one
would use the read function, if so how does that work, does it it
retreive this from some kind of queue? and at some point I check if
there is anything in the queue then retreive it?
I'm just really confused as far as getting the non-blocking socket set
up and how to use it, all the other posts talk about the different
variables you can pass, well I guess that is setting it up, but i'm
still confused. Also I've yet to see an example of this code in
context, so I wonder, where should this be called? if thats now
relevant how would I determine where I should call. Questions
Question! Next question, Whats the differance between fcntl and ioctl?
and what about setsocketopt function, can it be used to set the socket
to non-blocking?
Perhaps there are some very thorough tutorials that I am missing in my
google/google group searches that some one could point out to me. Or
if some one could show me how to properly set the socket up as
non-blocking and how to read from it I would be very gratefull.
I've also read forking with blocking as an option. Not sure if this is
a viable solution but would it be similiar if you forked of a seperate
process with the listener socket and each time a connection was
accepted fork it off to yet another process so that the original
process could continue listening? if thats an option what be the
advantage of forking the program over using non-blocking sockets.
- Next message: Bryan Castillo: "Re: "System V IPC is a botch?""
- Previous message: Kurtis D. Rader: "Re: Help : error warning: modified (chunk-) pointer"
- Next in thread: David Schwartz: "Re: Trying to learn Non-Blocking sockets on Solaris 8, please help! ready to fork() it."
- Reply: David Schwartz: "Re: Trying to learn Non-Blocking sockets on Solaris 8, please help! ready to fork() it."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|