Java Reference
In-Depth Information
Each Datagram instance represents a single message either waiting to be written to the
connection or previously read from the connection; you can reuse a Datagram instance by
invoking its reset method. You can also query the various properties of a Datagram using
the following methods:
getAddress : Returns the address of a Datagram
getData : Returns the contents of a Datagram 's buffer
getOffset : Returns the offset into a Datagram 's buffer
setData : Lets you set a Datagram 's buffer, offset, and length given an array of bytes
setLength : Lets you set the length of a Datagram 's buffer
Communicating with HTTP
After the protocols that deliver e-mail, HTTP is perhaps the most widely deployed and
understood protocol for data exchange today. At heart, it's a simple client/server proto-
col, and its simplicity and generality have led it to be one of the most important protocols
on the Internet today. Besides being the protocol responsible for delivering content on
the Web—created by Tim Berners-Lee, it has its origins in providing the transport for
hypertext documents at the European Organization for Nuclear Research (CERN)—it
now underpins many other client/server exchanges, such as those enabling web services.
(I talk more about the web service model of computing in the next chapter.)
Reviewing HTTP
HTTP is a client/server protocol in which a client application—the user agent —makes a
request of a server for an operation or content located at a particular URL. The request
consists of headers that contain metadata about the request, and an object body , which is
an optional block of data that pertains to the request. The server replies to the request in
the same way, returning headers that provide metadata about the request followed by an
optional object body in response. HTTP can run over any reliable stream protocol, but in
common practice, it operates over TCP. The protocol itself uses an eight-bit representa-
tion for characters, but the request and response headers are written as plain text,
making it easy for developers to understand, implement, and troubleshoot. For example,
a client web browser might send the message in Listing 12-5 to obtain the home page at
the URL http://www.noplace.com .
 
Search WWH ::




Custom Search