Chabot College Fall 2002
Removed Fall 2006
Course Outline for Computer Science 18E
LINUX SOCKETS PROGRAMMING II
Catalog Description:
Computer Science 18E - Linux Sockets Programming II 2 units
Continuation of Computer Science 18D. Advanced socket programming: using standard I/O on sockets, concurrent client servers, socket options, broadcasting, out-of-band data, the inetd daemon, network security and file handling. Development of several networked systems programs. Prerequisite: Computer Science 18C and Computer Science 18D (both completed with a grade of C or higher). 1.5 hours lecture, 1.5 hours laboratory.
Prerequisite Skills:
Before entering the course the student should be able to:
1. demonstrate familiarity with the TCP/IP protocol suite and the general history of how it came to exist;
2. demonstrate familiarity with the general history of the Internet and networking in general;
3. create and manipulate a socket in a C program under Linux;
4. describe a client-server and a peer-to-peer network relationship;
5. resolve domain and address families using system calls in Linux;
6. work with both big-endian and little-endian hardware byte orders;
7. form a socket address;
8. work with an abstract local address;
9. identify when socket addresses are not required;
10. manipulate IP addresses and do address conversion, if needed;
11. use an IP netmask;
12. identify private and reserved IP numbers;
13. use Linux system calls that convert IP numbers;
14. identify the classes of IP addresses and be able to identify address of each class;
15. use the domain, socket type and protocol arguments for socket functions;
16. bind an IP address to a socket;
17. get a local socket address from a socket that already has an existing address;
18. get the socket address from a peer socket;
19. use bind() to choose a network interface to use for communication;
20. use connectionless protocols (UDP) over a socket connection;
21. use connection-oriented protocols (TCP) over a socket connection;
22. demonstrate a knowledge how and when to use either type of protocol;
23. identify the differences between Linux operating system file services and the C file library;
24. use Linux services to provide file access in small C programs;
25. identify the major types of Linux resources that can be accessed as files: regular files, named and unnamed pipes, directories, devices, symbolic links and sockets;
26. use any of these (except sockets) in a C program on Linux;
27. identify, use, and set owner, group and other permissions on a file or directory;
28. use Linux file access functions: creat, unlink, open, close, read, write, seek, and ioctl;
29. move around in a directory tree, and create or remove directories;
30. implement multiplexed file access using fd_set and select;
31. lock and unlock files and records;
32. manage memory-mapped files;
33. write a simple Linux shell that executes commands, creates pipelines, does I/O redirection, and uses a tee correctly;
34. create and use a library;
35. create and use a daemon.
Chabot College Page 2
Course Outline for Computer Science 18E
Linux Socket Programming II
Fall Semester 2002
Expected Outcomes for Students:
Upon completion of the course the student should be able to:
1. use the ANSI standard C I/O calls on sockets, associate a socket with a FILE stream;
2. deal with problems related to using standard I/O on streams;
3. handle an interrupted socket fread() or fwrite() call;
4. write a server to handle concurrent clients, using fork(), wait(), waitpid(), and select();
5. retrieve socket options with getsockopt();
6. set socket options with setsockopt();
7. use the most commonly needed socket options;
8. broadcast over IP using UDP: establish a UDP socket, send broadcasts with the socket, and receive broadcast messages with a socket;
9. identify out-of-band data and handle it in a program;
10. identify the inetd daemon and use it;
11. identify and handle network security issues.
Course Content:
1. Using standard I/O on sockets
a. How to associate a socket with a FILE stream (with fdopen())
b. How to create and apply read and write FILE streams
c. Issues concerning stream oriented I/O on sockets and closing the socket
d. Buffering with FILE stream sockets
e. Handling interrupted system calls
2. Concurrent client servers
a. Handling multiple clients from one server
b. The fork(), wait(), waitpid() and select() system calls
3. Socket options
a. Getting and setting socket options with getsockopt() and setsockopt()
b. The most used socket options and how to apply them
4. Broadcasting (with UDP)
a. Establishing a broadcast UDP socket
b. Sending and receiving broadcast messages over sockets
5. Out-of-band data
a. Define out-of-band data
b. Why is out-of-band data needed?
c. What socket-related issues arise with out-of-band data?
d. How does TCP/IP handle out-of-band data?
e. How do you support out-of-band data with TCP stream sockets?
6. Inetd daemon
a. What inetd is
b. The server resource utilization issue, and how inetd solves it
c. How inetd simplifies writing servers
7. Introduction to network security issues (optional as time permits)
a. How the inetd daemon can be used with the TCP wrapper concept to provide screening of clients
b. How the TCP wrapper concept works
c. Shortcomings of the TCP wrapper concept
8. Passing credentials and file descriptors (optional as time permits, or omit altogether -- this is generally for advanced students only)
a. User credentials
b. How to get them locally, or to a local server
c. How to send and receive user credentials
d. How to send a file descriptor to another process on a local host
e. How to receive a file descriptor from another process on a local host
Chabot College Page 3
Course Outline for Computer Science 18E
Linux Socket Programming II
Fall Semester 2002
Methods of Presentation:
1. Lecture
2. In-class example programs with explanations and demonstrations
Assignments and Methods of Evaluating Student Progress:
1. Typical Assignments
a. Programming homework illustrating main points from lectures, such as:
1) A program using out-of-band data to communicate directly between sockets independently of the main application messages.
2) A multi-client server and several servers to drive the client (or use clients written by several different students).
b. Non-programming homework to reinforce concepts from lecture and reading
1) Write a timing diagram showing the sequence of operations that occur when processing client messages from a concurrent client server.
2) Examine a set of IP addresses, showing which class they belong to and what netmasks will cause them to be considered local subnet addresses.
2. Methods of Evaluating Student Progress
a. Midterm Exam
b. Optional short quizzes
c. Final exam
Textbook(s) (Typical):
Linux Socket Programming by Example, Warren W. Gay, Que Corporation, 2000
Special Student Materials:
Computer lab fee
Diskettes
Optional zip disk
Revised: July 2001
Keith Mehl
CS 18E Outline Fall 2002
hps