[comp.unix.questions] Client/Server using Sockets??

ikhan@mentor.com (Iqbal Khan) (01/01/91)

I am using unix sockets for a client server modem.  On the server side
I am using 'listen' and 'accept' for connections and on the client
side I am using 'connect'.

My problem is that I want to allow only one connection at a time. This
means that if the server has accepted a connection, all other
connections should be refused, instead of being put in the queue.  I
have tried using 'backlog' of 0 in the 'listen' command but it did not
solve the problem.  Here are a few lines on the server side:

/****************************************************************/
  if (listen(sock,0) < 0) {   /* backlog is zero */
    perror("listening for connections");
    close(sock);
    exit(1);
  }

  ...

  msgsock = accept(sock,(struct sockaddr *) &addr,&len);
/****************************************************************/

I would appreciate any suggestions. Please send e-mail to
'ikhan@mentor.com' or 'khan@iuvax.cs.indiana.edu'.

Thanks in advance.

Iqbal Mustafa Khan
503-626-7000 (x7256)

P.S. My platform is apollo and O.S. verison 10.3.
-- 
Iqbal Mustafa Khan