Tutorial Week 14
If a server wishes to broadcast a message to all clients, what are the advantages
and disadvantages of
a) connection-oriented
b) connectionless
transmission?
Ans:
In a connection-oriented system, all clients would have to connect to the server,
which would be impractical as they would not know that a message was coming.
Alternatively, the server would have to connect to all clients, assuming that
it knew them all. So this looks ot so good. On the other hand, this would ensure
that all clients did get tbe message, or at least that the server would know
about it. In connectionless broadcast, the server would not know if anybody
missed a message, and would not have any security on who received it. On the
other hand, it would not have to do anything special.
A server may wish to receive requests on more than one port. How can this be
done?
Ans:
It would have to poll each port in turn, looking to see if anything comes on
any one of them. ie this must be non-blocking reads/selects from the port.
If a process is sending debit and credit requests as individual messages, should
a connection-oriented or connectionless protocol be used?
Ans:
In a connectionless system there is no guarantee that messages will arrive
in the order sent. So to ensure that a debit is done before the credit, a connection-oriented
version would be used.
How can a two-byte short integer be encoded into a four-byte word so that it
can be read correctly on both big-endian and little-endian machines? How can
two machines (that each know their own ordering) decide whether to byte-swap
incoming messages?
Ans:
Encode the two-byte xy as the 4-byte xyyx. That way either way of reading will
get xy. If the first word is an ``order'' flag eg 1001 for big, 0110 for little,
then the receiver will be able to determine the byte order of the incoming
message and hence whether or not to swap it.
Laboratory Week 14
The ``finger'' service can use either TCP or UDP. With TCP, it expects to be
sent an empty line, that is a buffer with just a newline in it. It returns
a list of all people logged in and then closes the connection. Write a TCP
finger client that takes an Internet address and prints who is logged on at
that host.
A coca-cola machine has been connected to the Internet, so that when you finger
it, it returns the number of cans it contains, etc. Its address is coke@cs.cmu.edu.
Another one is at drink@drink.csh.rit.edu. Random Star Trek quotes are given
by franklin@ug.cs.dal.ca. Use your finger program to connect to these.