Computer Networks

Tutorial #6

  1. What is a socket? In what ways is a socket different from a file under Unix? In what ways is it similar? Why are these differences and similarities historically important?

  2. In the lecture, it was stated that the bind() system call was not normally needed in client software. Why not? Why is it needed for a server? NB: What this question is asking, in part, is what bind() actually does - if you understand this, you should know the answer.

  3. When1 is the listen() call important?

  4. The read() system call specifies a maximum number of bytes which may be read from a socket. Do you think it can return less than this? Under what circumstances? What if the write() system call returned a different value from that given in its length argument?

  5. The following is a line of code from a program written in the Java language:
    mySock = new Socket("www.latrobe.edu.au", 80);
    
    Even if you nothing whatsoever about Java, can you suggest what this line of code does? How does it compare to the "C" code described in the lecture? For real Java whizkids: why wouldn't you normally write a program containing a line like this?

  6. Are sockets the only conceivable way in which TCP connections can be managed? Why are they so commonly used?

  7. (Very difficult question2) The second last slide made brief mention of the way in which the accept() system call returned a new socket. How is this used, and why is it a pretty nifty trick? Note: the answer is not at all obvious. Java experts might like to discover how Java uses threads to handle this situation.

Practical exercises:


1 From Comer, P363.
2 Seriously. You are not expected to understand this for this subject. However, people who have already taken a subject such as BITSYS: System Software will see what's going on here.
[Previous Tutorial] [Tutorial Index] [Next Tutorial]
Phil Scott