Socket help wanted
SANDEEP at S63.Prime.COM
SANDEEP at S63.Prime.COM
Tue Jul 25 02:30:00 AEST 1989
scm at datlog.UUCP writes :
>I have an application which listens on a well-known port, accepts a
>connection and execs a child process, then awaits further connects.
Please read my previous response as:
#define MAXBACK 1
int numconn;
server()
{
int oldmask,mask;
numconn = 0;
/*create and bind socket */
signal(SIGCHLD,decnumconn);
for(;;) {
if (numconn < MAXCONN) {
err = listen(s,MAXBACK);
mask = signal(SIGCHLD);
oldmask = sigblock(mask);
numconn++;
sigsetmask(oldmask);
/* accept,fork, etc. */
}
}
}
decnumconn()
{
numconn--;
}
client()
{
/*create and bind socket */
while ((connect(..,..,..) < 0) {
if (errno != ECONNREFUSED) return(-1); /* or whatever */
}
/* transfer data */
}
--------------------------------------
In_Real_Life: Sandeep Srivastava Prime Computer, Natick, MA 01701.
Internet : sandeep at s63.prime.com 508-879-2960x3711
/* End of text from S63:comp.unix.questions */
More information about the Comp.unix.questions
mailing list