Q: Would the server be considered to be concurrent if we just
did not call connect() on the socket and then handled a mixture of
incoming packets on the same udp socket? Is this even possible?
Since udp is connectionless, I figure that two clients can be talking
to the same server at the same time, as long as the server is capable
of distingushing between the two.
A:
Sure, although there is support for handling this problem built in to
TFTP. The server is expected to respond to the initial request from a
new UDP port number - all subsequent communication with the client is
done through this new dedicated port. (Check out section 4. Initial
Connection Protocol of RFC 783 -
TFTP for more information on this.). So, in fact - the server
can call connect. BUT this means the server has to worry about
multiple sockets, since if you do it all in a single process the
server will need to have a seperate socket for each client.
Of course you don't _need_ to use a different port for each client,
the client just assumes that the port number from which the initial
reply comes is the port number it should be sending to (not the well
known port). If you want to try to do the multiplexing yourself you
are free to try.
The "simple" way to provide concurrency is just to fork() a child for
each client and to have each child create a new UDP socket (port) that
is used to handle the client. All incoming requests will be sent to
the well known port that the parent process is looking at. The only
thing to watch out for is that the parent process cleans up after all
the child processes (calls wait()).