Unix Network Programming
Computer Engineering: 240-426
Assignment 1 due date: December 26, 2003
Assignment 2 due date: March 1, 2004
Lecture 1:
- Introduction to the Subject
- Teaching methods, etc.
- Assessment
- Books
- Review of Unix & System Calls
Lecture 2:
- Unix I/O
- System Calls
- File Descriptors
Lecture 3:
- Unix Device I/O
- Pipes & other IPC
- Protocols
- The ISO Reference Model
- ISORM Layers
- Unix & network layers
Lecture 4:
- Addressing
- Link Level Addressing
- Individual and Group Addresses
- Network Addressing
- Addressing for various protocols
- IP addressing
- Transport Addressing
Lecture 5:
- Address Families
- Connection Oriented and
- Connectionless communications
- Some Terminology
- Client Network Process outline
- Server Network Process outline
- Creating a socket
Lecture 6:
- Socket Addresses
- Socket address storage
- Various protocol sockaddrs
Lecture 7:
- Number Representation
- Network Byte Order
- Conversion between Network Order and Host Order
- Obtaining Addresses
- The History
- -- HOSTS.TXT and /etc/hosts
- -- gethostbyname() and where it originated
- -- extension to handle DNS queries
- -- gethostbyname2() for IPv6, and why
Lecture 8:
- gethostbyname() revision
- -- and example usage
- gethostbyname() and IPv6
- gethostbyname2()
- Becoming more portable
- getaddrinfo() & friends
- The addrinfo strcuture
- Example getaddrinfo() for a client
- Example getaddrinfo() for server
- -- using the getaddrinfo hints
Lecture 9:
- Manipulating addresses
- getnameinfo()
- inet_ntop() & inet_pton()
- gethostbyadd4r() and IPv6
- Accepting Connections
- listen()
- accept()
- sample usage
Lecture 10:
- Remaining pieces of simple client/server
- closing sockets
- -- close() & shutdown()
- data transfer
- -- read() & write()
- -- recv() & send()
- The Internet Daemon
- Assignment 1 (copy available in PDF format)
Lecture 11:
- Multiplexing I/O
- -- the reason
- -- operations that block
- Traditional OS asynchronous I/O
- Original unix method
- -- fork() & one process per operation
- -- limitations
- ioctl solutions
- -- FIONREAD
- -- FIONBIO
- -- FIOASYNC
- requirement to eventually block
- select()
- File descriptor sets
- -- operations upon them
- -- introduction to select()
Lecture 12 & Lecture 13:
- select() and how it works
- -- Its disadvantages
- poll() as an alternative to select
- -- data structures
- -- calling sequence & function
- poll events
- Working client/server examples
- - client (trivial send & receive)
- - simple server (one client at a time)
- - simple forking server (fork for multiple clients)
- - Demonstration of deadlock
- - multiplexed server (select - avoids deadlocks)
Gzip'd Tarball of client & servers
Lecture 14
- Datagrams, and their properties
- sending datagrams: sendto()
- Example of sendto()
- Receiving datagrams: recvfrom()
- Example datagram server
- Dealing with the nature of datagrams
- -- packet loss, duplication, reordering
- Server behaviour
- Client behaviour
- Example datagram client
- Connected datagram sockets
- Datagram system call restrictions
Lecture 15
- Revision for mid-term examination
Lecture 16
- The Protocols
- -- TCP UDP IP (and sockets)
- Socket & protocol options
- -- getsockopt()
- -- getsockopt()
- Some socket options
Lecture 17
- Socket options for IP
- Socket options for TCP
- Socket options for UDP
- Out of Band Data (intro)
Lecture 18
- Out of Band Data
- TCP Urgent Data
- Unix facilities for dealing with OOB
- Sending OOB data
- Receiving OOB data
Lecture 19
- Example of a network server
- --   code walkthrough
C code available here
Lecture 20
- Processing Unix Signals
- Causes & types of signals
- -- different default behaviours
- Catching Signals
- Signal Handlers
- Caught signal inheritance (fork/exec)
- Defined signal "handler" names
- -- default, ignore & error return
Lecture 21
- Signal Handler Functions
- Interruptable system calls
- Race Conditions
- -- internal to library functions
- Safe signal handler code
- Catching Signals
- Avoiding Race Conditions
- Inapplicability of semaphores & critical regions to interrupt routines
- Blocking Signals
Lecture 22
Lecture 23
- Other IPC forms
- Shared memory, mmap and shm
- mmap interface & mapped files
- Semaphores
- System V messages
- Pseudo Terminals
- -- rationale & function
- Pseudo terminal operations
- Allocating a pty
- Cloning devices