[comp.unix.questions] TCP programming question

rcb@ccpv1.cc.ncsu.edu (Randy Buckland) (06/29/90)

I have a program that is trying to use "select" to listen to a pipe,
a tcp socket with a known port number and any number of active "connected"
tcp circuits. I would like select to complete when another process issues 
a connect request for the tcp socket with the known port number and select
would indicate that file as having activity. I am setting the select
bitmasks for read and exceptions for all files involved. I thought that
a connect request would read as an exception, but I get nothing.

Any ideas? I want to be handling other data and when a connect comes in,
I would like to accept that connection and add the new file to the list of
active circuits.


--

Randy Buckland
North Carolina State University
rcb@ccpv1.cc.ncsu.edu (919) 737-2517

libes@cme.nist.gov (Don Libes) (06/30/90)

In article <rcb.646672934@ccpv1.cc.ncsu.edu> rcb@ccpv1.cc.ncsu.edu (Randy Buckland) writes:
>I have a program that is trying to use "select" to listen to a pipe,
>a tcp socket with a known port number and any number of active "connected"
>tcp circuits. I would like select to complete when another process issues 
>a connect request for the tcp socket with the known port number and select
>would indicate that file as having activity. I am setting the select
>bitmasks for read and exceptions for all files involved. I thought that
>a connect request would read as an exception, but I get nothing.

No, it comes in as a read (on the server's connection_socket).

>Any ideas? I want to be handling other data and when a connect comes in,
>I would like to accept that connection and add the new file to the list of
>active circuits.

Make this easy on yourself and ftp pub/sized_io.shar.Z from durer.cme.nist.gov
(or mail "send pub/sized_io.shar.Z to library@ the same host.)  It is a
library of networking utilities.  One is a function defined as:

	int client = select_server_stream(s,&fds);
	int s;
	fd_set fds;

select_server_stream() receives data or connections, and handles
client deaths.  s is the server's connection socket.  fds is the
fd_set required by select().

It includes some other utilities as well as a paper I wrote called
"Packet-Oriented Communications Using a Stream Protocol --or-- Making
TCP/IP on Berkeley UNIX a Little More Pleasant to Use".  Enjoy.

Don Libes          libes@cme.nist.gov      ...!uunet!cme-durer!libes