CSCI 373 Computer Networking — Chapter 9 comments
The API’s
socket
— low-level networking interface
socket.socket
s.bind
— for servers
s.listen
— for servers
s.accept
— for servers
s.connect
— for clients
s.recv
s.sendall
s.close
- Unix-style process management
os.fork
— for servers
os.execve
— sometimes for handlers
os._exit
— for handlers or they can just return
os.wait
— for servers
signal.signal
— for servers to avoid need for
os.wait
- threading
threading.Thread
— for servers to create handlers
t.start
— for servers to start handlers
- normal
return
— for handlers
t.join
— for servers
t.daemon
— for servers
- SocketServer — use complex OOP for simplification
SocketServer.BaseRequestHandler
— extend (or subclass)
by overriding handle
SocketServer.TCPServer
— creates TCPServer
object using
host and port tuple and a BaseRequestHandler
object
SocketServer.ThreadingMixInM
— “overrides” some methods of
SocketServer.TCPServer
to support threading
using multiple inheritance to define an
extension of SocketServer.TCPServer
poll
— for single-process non-threading servers
Types of servers
- handle Only one connection and exit
- handle multiple connections but one at a time
- handle multiple concurrent connections
but don”t let them share —
using Unix
fork
- handle multiple concurrent connections and let them share —
using threading
- handle multiple concurrent connections with
poll