TCP programming question

Don Libes libes at cme.nist.gov
Sat Jun 30 04:26:25 AEST 1990


In article <rcb.646672934 at ccpv1.cc.ncsu.edu> rcb at 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 at cme.nist.gov      ...!uunet!cme-durer!libes



More information about the Comp.unix.questions mailing list