[net.unix-wizards] TCP/IP and the server<->client model in 4.2BSD

djl@fisher.UUCP (Dan Levin N6BZA ) (12/14/84)

Ok wizards, here is your big chance to help a real problem child.
I am convinced I am missing a *major* clue here, but for the life
of me I cannot figure out what to do.

Here is the scenario.  I have a need to produce a system (a graphics
editor of sorts) consisting of one server and n clients, where n
is ~12.  The server will reside on a given machine (the VAX at the
center of a cluster of SUNs), and the clients are mixed arbitrarily
among the five SUNs on the network.  Thus, we can have from zero to
12 clients running on any one SUN, all talking to the central server.

For various reasons (and this may be the heart of the problem), I choose
to implement this beast using TCP/IP (ie. SOCK_STREAM/AF_INET, all machines
run 4.2BSD).  This decision was based mostly on the need for reliable
communications (I did not want to run the risk of using SOCK_DGRAM and
loosing packets now and then, the network is rather busy).

The question is, how can I make all the clients talk to one socket
on the server.  The way I have things arranged now, the client
makes a request to start up to a predetermined port, and the server
then gives the client his own send and receive ports for all future
communications.  This means that the server has to listen to
up to ~24 different ports, or does it?  It makes perfect sense to
me that each client have his own receiving port, at least on a per
machine basis.  Two clients on machine 'jojo' cannot both receive
at port 6666.  But, is it really the case that a client on jojo and
another on phred cannot both listen to port 6666 on their respective
machines.  And, more importantly, why does bind() prohibit more than
one client from sending input to port 6667 on the server's machine?

Pointers to manuals gleefully accepted, as are patient descriptions
of my more major blunders.  Please reply by mail, unless you
feel the content will interest the net.

Thanks,

-- 
			***dan

{allegra,astrovax,princeton,twg}!fisher!djl
The misplaced (What *are* those trees doing??) Californian

ron%BRL-TGR@tgr.UUCP (12/17/84)

> The question is, how can I make all the clients talk to one socket...

You can't but I don't think this is what you mean.  You want them to
tail to one port number.  Well,  you are allowed to do multiple accepts
on the same original socket.  Accept returns you new sockets rather than
just twiddling the one you give it (see accept(2)), just use the REUSEADDR
option.

The only problem that remains is how to multiplex new connections into
existing ones and you can handle this with select.  Select returns
a "ready for reading" condition when there is a connection available.

-Ron