Application Layer

2.8 Socket Programming with UDP

Home
Introduction
2.1 Principles of Network Applications
2.1.1 Network Application Architectures
2.1.2 Processes Communcating
2.1.3 Application-Layer Protocols
2.1.4 What Services Does an Application Need?
2.1.5 Services Provided by the Internet Transport Protocols
2.2 The Web and HTTP
2.2.1Overview of HTTP
2.2.2 Nonpersistent and Persistent Connections
2.2.3 HTTP Message Format
2.2.4 User-Server Ineraction: Cookies
2.2.5 HTTP Content
2.2.6 Web Caching
2.2.7 The Conditional GET
2.3 File Transfer: FTP
2.3.1 FTP Commands and Replies
2.4 Electronic Mail in the Internet
2.4.1 STMP
2.4.2 Comparison with HTTP
2.4.3 Mail Message Formats and MIME
2.4.4 Mail Access Protocols
2.5 DNS--The Internet's Directory Service
2.5.1 Services Provided by DNS
2.5.2 Overview of How DNS Works
2.5.3 DNS Records and Messages
2.6 P2P File Sharing
2.7 Socket Programming with TCP
2.7.1 Socket Programming with TCP
2.7.2 An Example Client/Server Application in Java
2.8 Socket Programming with UDP

Socket Programming with UDP

When two processes communicate over TCP, it is as if there was a pipe between the two processes.  This pipe remains in place until one of the two processes close it.  When one of the processes wants to send some bytes to the other process, it simply inserts the bytes into the pipe.  The sending process does not have to attach a destination address to the bytes because the pipe is logically connected to the sedtination.  The pipe provides a reliable byte stream channel--the sequence of bytes received by the receiving process is exactly the sequence of bytes that the sender inserted into the pipe.
 
UDP also allows two (or more) processes running on different hosts to communicate.  UDP differs from TCP in many fundamental ways.  First, UDP is a connectionless service--there isn't an initial handshaking phase during which a pipe is established between the two processes.  Because UDP doesn't have a pipe, when a process wants to send a batch of bytes to another process, the sending process must attach the destination process's address to the batch of bytes.