Network Programming with TCPIP UNIX
Sockets
- developed for Berkeley UNIX : recall early Berkeley TCP/IP implementation, first delivered with BSD 2.1
- central features: central abstraction – the socket – an end-point like an electrical connector, not TCP/IP specific (e.g. UNIX named pipes), uses normal read/write system calls, sockets associated with UNIX file descriptors but some not for normal I/O, some extra system calls
- sits more comfortably with TCP than with UDP because of byte-stream nature of UNIX I/O
- special UDP functions e.g., recv(…) – accepts a UDP datagram
- additional non-socket functions e.g., gethostbyname(…) – domain name server
Establishing a TCP Connection
Initial State
- TCP is connection based … establishing it is a complex multistage process
- initially all machines are the same
- no special ‘server’ machines
- the difference is all in the software
Passive Open
- server process does a ‘passive’ open on a port