references: Java Developer's
Handbook, Heller-Roberts, The JDK 1.2.2 documentation
"Java 1.1 The Complete Reference"
Naughton-Schildt, "The Hardware Bible", W.Rosch,
'Running Linux', Welch, Dalheimer
& Kaufman, 'Networking Complete', Sybex
The History of the Internet
In 1958 The Russians launched the Sputnik sattelite, effectively taking
the lead in the
space race. That was a shock to the western world at the time. The
Americans were
the first to develop the nuclear bomb. The Russians had it soon after.
This period in
time marked the height of the cold war. If nuclear bombs were going
to be exchanged,
they would be carried on rockets that travelled through space. President
Eisenhower,
who had been a one of the victorious American generals of the second
World War
responded to the Sputnik launch with different initiatives, one which
was ARPA, the
Advanced Research Project Agency. ARPA was started
under the auspices of the
as part of the Department of Defence. ARPA became
better known as DARPA
and sponsored a lot of work at various Universities.
At that time computers were not
connected and you had to be at the school whoowned
it to work on it.
A Vision of the Internet
In 1962 J. Licklider, soon after being appointed the head of research
at DARPA wrote
a series of memos describing a "Galactic Network", a vision of a global
network of
computers which could be accessed as a single collective from any one
site. Licklider
passed the concept on to his successors at DARPA, Ivan Sutherland,
Bob Taylor,
and MIT researcher Lawrence G. Roberts.
Packet Theory
MIT researcher Leonard Kleinrock in 1961 published the first paper on
packet switching
theory. Kleinrock made the case that communications could be based
on packets rather
than strictly on circuit connections. ( The idea of grouping sets of
signals that traverse a
wire in packets.) In 1964 he wrote a book to further support his theory.
Parallel Tracks
Meanwhile, Paul Baran and others at RAND had written a paper on packet
switching
networks for secure voice in the military in 1964. As well Donald Davies
and Roger
Scantlebury of British
National Physics Laboratory, NPL from the United Kingdom.
had also written a paper on a packet network concept from the UK. Apparently
all
three groups were developing the packet based communication systems
independantly.
From the time line here described it seems Kleinrock has the earliest
paper published
on the topic. (The word "packet" was apparently adopted from the work
at NPL.)
The First WAN
In 1965 working with Thomas Merrill, Roberts connected a computer in
Massachusetts
to one in California with a low speed dial-up telephone line creating
the first WAN or
wide-area network.
In 1966 Roberts proposed to DARPA a plan to build a computer network
called the
ARPANET. His proposal was published in 1967.
Kleinrock's Center at UCLA was the first ARPANET node and connected
was
connected to a second node supervised by Doug Engelbart at the Stanford
Research
Institute. The SRI supported the Network Information Center ( NIC )
led by Elizabeth
Feinler which maintained tables of host name to address mapping and
a directory of
RFCs. Two more nodes were added to UC Santa Barbara (managed by G.
Culler
and B. Fried) and and the University of Utah under the supervision
of Robert Taylor
and Ivan Sutherland. By the end of 1969 there were 4 nodes on the ARPANET.
(Robert Taylor and Ivan Sutherland were also actively investigating
how to represent
3-D representations graphically over the net.)
Computers were added at a quick rate after this time. In 1970, S. Crocker
led a group
that finished the first ARPANET Host-to-Host protocol, called the Network
Control
Protocol (NCP). In 1972 e-mail was introduced. The basic email program
was written
by Ray Tomlinson which was expanded upon by Lawrence Roberts.
Robert Kahn developed an architecture for network communications to
take place at
the operating system level. The architecture he devised maintained
that networks were
stand-alone units and not dependent on the Internet to continue functioning.
He chose
a packet transmission policy where packets that didn't reach their
target would be
retransmitted. He envisioned the different networks being connected
by 'black boxes',
what would become gateways and routers. These boxes would pass packets
but not
retain any information keeping them simple and quick to recover from
failure. Finally,
Kahn included the idea that there would be no global or centralized
control of the
internetwork's operations.
Kahn teamed up with the operating system expert Vint Cerf to create
a practical
blueprint for the communication scheme and at a conference at Sussex
University
in September of 1973, they spelled out would was the effectively a
specification for
the TCP protocol. The original paper had only described the TCP protocol.
It was
going to be able to provide a reliable service where all packet deliveries
were
acknoledged, and an unreliable datagram model where an occasional loss
of a
packet could be tolerated. In the end, TCP was implemented with only
the virtual
circuit model, where packet delivery was acknowledged. This led to
reorganizing
the model into three parts. The TCP protocol handled flow control nd
lost packet
recovery. The IP protocol would deal addressing machines and seeing
that packets
arrived at their destinations. The UDP or User Datagram Protocol would
provide
a broadcast delivery service where packet loss was ignored. Transmission
Control
Protocol was first used in 1977.
DARPA supported efforts at UC Berkeley to investigate
adapting TCP/IP to the
Unix environment. Berkeley researches rewrote
the TCP/IP code so it would work
efficiently with Unix. By 1984 Berkeley Unix
was released as version 4.2 BSD. The
TCP/IP support found in 4.2 became the de facto
standard for the Internet. The
socket model for for interprocess and network
communication, popularly known
as 'Berkely sockets', became widely adopted in
other operating systems such as
those of Microsoft and Apple. The incorporation
of Unix in BSD Unix was then, an
important step in popularizing the TCP/IP protocol
with computer researches at
various academic institutions.
The Beginning of IP addresses
Originally, it was felt there would only be a small number of national
level networks.
A 32 address scheme was devised where the first 8 bits would be used
to describe
the networks. This design would soon need to be modified.
Requestsfor Comments (RFCs)
The academic branch of the DARPA project followed the tradition of open
publication
of ideas and results. In 1969, S. Crocker established the Request for
Comments series
of shared memos to share information between researchers. FTP, File
Transfer Protocol
replaced paper and conventional mail as the preferred way of communicating
RFCs. Now
the RFCs are widely available in the form of HTML pages on the world
wide web. Over
time these informal communications became a forum for formal documents
and the release
of official specifications. Today, the RFCs are also regarded as being
the record of
documentation of the Internet.
.
The Origin of Telnet
In these days, the mainframe computers at the hearts of the various
institiutions that
were connected to the early ARPANET were extremely expensive. TELNET,
a
program that supplied a remote terminal to a mainframe was initially
conceived as
a way of sharing access to the valuable resource.
In 1983, ARPANet switched from Network Control
Protocol to TCP/IP in recognition
of TCP/IPs increasing dominance as the primary
communication protocol of the Internet.
By this time the original ARPNet was one of many
interconnected networks.
The World Wide Web
Tim Berners-Lee, working at CERN in Geneva
in 1990 co-authored with R. Fielding
and H. Frystyk the RFC entitled the HyperText
Tranfer Protocol. This along with the
invention of HTML by the same researchers, led
to the creation of the World Wide
Web and the Internet as we know it today with
it's browsers and accompanying
plethora of images and hyperlinks.
The Domain Name Service
To give the Internet Addresses a human handle,
domain
names are provided. To help
cover an expected shortage in names, the International
Ad Hoc Committee, proposed
seven additional suffixes in addition to the
six already in use. Most recently (2000)
congestion is expected to be further alleviated
by newly announced expansions of the
names that will be available on the Internet.
Internet Domain Name Suffixes
Ending | Application |
.arts | cultural groups |
.com | business & individuals |
.edu | schools |
.firm | business |
.gov | government |
.info | information services |
.mil | military |
.net | ISPs |
.org | groups & organizations |
.nom | individuals |
.rec | recreational sites |
.store | retailers |
.web | web organizations |
Following are some short takes for orientation of terms from one of the online encyclopedias.
TCP/IP
Transmission Control Protocol/Internet Protocol
A communications protocol developed under contract from the
U.S.
Department of Defense to inter-network dissimilar systems.This de facto
UNIX standard, which is the protocol of the Internet, is becoming (most
would now say, has become) the global standard for communications.
TCP
provides transport functions, which ensures that the total amount of
bytes sent is received correctly at the other end. UDP is an alternate
transport that does not guarantee delivery. It is widely used for realtime
voice and video transmissions where erroneous packets are not
retransmitted.
IP
Internet Protocol, the IP part of the TCP/IP communications
protocol.
IP implements the network layer (layer 3) of the protocol, which
contains a network address and is used to route messages to
different networks or subnetworks. IP accepts "packets" from the 'layer
4', transport protocol (TCP or UDP), adds its own header to it and
delivers a "datagram" to the 'layer 2', data link protocol. It may also
break
the packet into fragments to support the maximum transmission unit
(MTU) of the network.
UDP
User Datagram Protocol,
a protocol within the TCP/IP protocol suite
that is used in place of TCP when a reliable delivery is not required.
For example, UDP is used for realtime audio and video traffic where
lost packets are simply ignored, because there is no time to retransmit.
If UDP is used and a reliable delivery is required, packet sequence
checking and error notification must be written into the applications.
port number
In a TCP/IP-based network such as the Internet, it is a number assigned
to an application program running in the computer. The number is used to
link the incoming data to the correct service.Well-known ports are standard
port numbers used by everyone; for example, port 80 is used for HTTP
traffic on the web.
data
packet
Most data communications is based on dividing the transmitted message
into packets. For example, an Ethernet packet can be from 64 to1518
bytes in length.
-Computer Desktop Encyclopedia
A protocol is a set of rules for
communcation. In network communcation, a protocol may
dictate the overall length of a packet, the relative size and content
of the fields within the
packet and how the contents of the packet should be interpreted. For
instance, a TCP
packet contains 11 fixed-length fields and one variable field that
carries user data. Each
of the first 11 fields of the header contain values that the protocol
uses to operate. A
sender and the receiver agree to communicate via this set of rules
which is the protocol.
Breakdown of a TCP packet
Source ID
| Destination
ID
|
| Sequence number
|
| |
ACK number
|
| |
|
Header length
|
| |
|
| Unused
field names
|
| |
|
| | Flags
|
| |
|
| | | Flow control
|
| |
|
| | | |
CRC 16
|
| |
|
| | | |
| Urgent Pointer
|
| |
|
| | | |
| |
Option
|
| |
|
| | | |
| |
|
User Data
|
| |
|
| | | |
| |
|
|
|
| |
|
| | | |
| |
|
|
||||||||||||||| |||||||||||||||| ||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||| |||| |||||| |||||| |||||||||||||||||
|||||||||||||||| |||||||||||||||| |||||||||||||||||||||||||||||||||| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
16 16
32
32
4 6 6 16
16 16
16
variable
number of bits per field
Frame and Packets
There is a bit of ambiguity about what defines a frame and a packet.
In networking it is
common to describe frames as being the carrier which may contain the
packets from
different protocols. From the glossary of a well-respected networking
book a frame is
described as
"a group of data bits at each end to indicate the beginning
and end of the frame.
Frames also contain source addresses, destination
addresses, frame type identifiers,
and a data message. Also called a packet.
-' Business Data Communications and Networking ',Fitzgerald & Dennis
Another networking text, 'Networking Complete' by Sybex states
" a data field that contains
protocol information is referred to as a packet. While the
term is sometimes used
interchangeably with the term frame, it in fact only describes
a portion of a frame."
In general when you are reading when reading networking literature,
the frame and the packet
are often used interchangeably to describe the unit that is being sent
over the network.
TCP/IP Layers
Networking specialists have found it useful
to breakdown the into layers the different
working levels that the devices, software, protocols
and applications work at. It is a
convenient and surprising useful method of interpreting
network information. \
Layers of the TCP/IP Model
Application |
Transport / TCP/UDP |
Network / IP layer |
DataLink |
Physical |
// the TCP/IP model groups the top three layers of the OSI model into one application layer
The TCP/IP System defines five layers or operation. (It actuallly predates
the publication
of the 7 layer OSI
(Open Systems Interconnection)
published by ISO, the International
Standards Organization.)
// ISO actually comes from the greek isos meaning equal
Layer 1: The
Physical layer -handles the actual transmission and reception
of data over
the network cable, satellite or other connection medium. The physical
layer includes the NIC
or the network interface card. //
i.e. electromagnetic radiation, signals running over the wire
Layer 2: The Data
Link Layer. At this layer, data
is split into packets to be sent across
connection medium. These are the units of Ethernet or Token ring. The
Data Link Layer
may use electronic techniques to ensure data integrity is maintained
in the delivery of data
to target destinations. //
at this layer NICs, (network Interface cards) exchange packet of data
Layer 3: The IP
/ Internet Protocol Layer When this layer receives data
from the layer
below it checks the header to determine if it is the intended recipient
of that data. In reverse,
the IP layer adds a header containing a destination address to a data
packet and passes it
down to the physical transmission layer. (IP functions like network
system configuration and
routing control are not Java language controllable.)
// reads / writes Internet address
Layer 4: The Transmission
Control Protocol and User Datagram Protocol
Either will
add a second header containing a port number
to the datagram (before passing them down
to the IP layer) In reverse, the TCP layer 'inspects' datagrams passed
up from the IP layer to
determine the port destination. In addition a
TCP data block has a sequence number
and a checksum. The sequence number
allows ordering of datagrams. The checksum allows
a determination of whether the data block was received correctly, (as
in, received by the
intended recipient and the recipient was ready to receive it). If correctly
transmitted, the
protocol requires the recipient to send an acknowledgement of receipt
which, if not received
in a reasonable length of time, will result in the sender retransmitting
the data. Frequent failures
results in abandoning the attempt to send the data. //
the port number is key to selecting a service
UDP has no acknowledgement
mechanism so hasn't the ability to inform a sender of failure
in communications (thus comes it's nickname, "Unreliable Data Protocol')
It has less 'overhead'
than TCP so is used in for streaming of media data. It is the broadcast
protocol of the TCP/IP
suite of protocols. // UDP
is a connectionless broadcast protocol
// Layer 4 reads/writes port #, gets/sets packet order, confirms packets are received & does error checks
Layer 5: The Application
Layer This layer incorporates the top three of seven layers
that
are defined in the ISO standard, the OSI
(Open System Interconnection) model.
This
includes a session layer which
establishes and coordinates connections between two
computers, a presentation
layer, where files get converted from one format to another,
( ie.this might be the case in communications between computers using
differing operating
systems or file systems), and the application
layer where high level protocols are
communicated from within applications. //
the applications like FTP or HTTP, not FoxPro etc.
Streaming Formats // a bit redundant, a review of encoding in a streaming context.
Streams of bits flowing over networks are deciphered according to different
data formats.
The most familiar is ASCII, the American Standard
Code for Information Interchange.
ASCII is a 7-bit code providing 128 character combinations, the first
32 of which are control
characters. The character is transmitted in an byte with an extra
bit left over which may be
used differently by different systems as a control flag. Most
of the long standing TCP/IP
services use ASCII data streams.
It has the advantage of being a universally accepted
standard, woven into the fabric of keyboards, printers, screens and
Internet Services but
has a limited
ability to communicate information internationally.
Unicode, is a character
set defined by the 'The Unicode Consortium'.
It is an assignment
of unique numbers to approximately 30,000 world characters and, aside
from adding a few
rules of syntax, is identical to the first plane of the ISO standard,
ISO-10646. Java uses
Unicode internally to encode characters and strings. It is
a good format to choose
for
streaming information in various world languages.
However,
since it is not the de facto
standard, it's use may be limited to participating
systems. Other problems are the lack
of
intrinsic hardware and Internet support
for 16-bit data formats. Additionally, it requires
twice the bandwidth of an equivalent ASCII
transmission.
UTF-8 (UCS tranformation format)
is an ASCII compatible, multibyte Unicode and UCS-
encoding format used by Java. It avoids the
problems of fixed-length Unicode encodings
by using multiples of 8 bits to encode characters. This way, ASCII
characters are encoded in
UTF-8 identically with the original format, Unicode characters take
two bytes or three bytes.
This allows UTF-8
encoded text to 'behave
normally' (that is use a single byte) with
established ASCII tools and services while
still being able to address the full range
of Unicode characters.
Binary may be the
best choice the large volumes of non-textual data. It's
disadvantage
is different systems have different formats
for interpreting primitive data streams.
This is not a problem between two systems written in java using symetrical
protocols.
IP Addresses and Domain Names
TCP/IP addresses
On a TCP/IP network, each machine is assigned
an IP address, a
32-bit number uniquely
addressing a machine. TCP/IP addresses uses a
dotted decimal format where four 8-digit
binary numbers (each represented by up to three
digital numbers) called octets
are
interconnected by periods.
IP Address Example 195.222.55.33 // format is xxx.xxx.xxx.xxx
//
An 8-digit binary number is a byte with a range 0 to 255. In IP addresses
the numbers
// used are normally 1 to 254
(Some values are reserved for special functions)
This IP address may be logically ANDED with a complimentary number in
the same
format called the Subnet Mask.
The Subnet Mask is used to separate out the net
part of the the IP address.
IP Submask Example 255.255.255.0
The 255 is in binary 11111111, which when ANDED with the IP Address
separates
out the network portion. A subnet mask like 255.0.0.0 isolates a class
A network. A
mask like 255.255.0.0 isolates a class B network. A mask like 255.255.255.0
masks
for a type C network. There are class D and E networks but they are
not available for
network use.
To address the problem of a shortage of internet addresses a new standard
is expected
to be implemented, IPv6, which
uses 16 byte addresses which will yield a possible
3.2 x 10 38 addresses.
Example of mask use
255.255.255. 0
200.17.75.20
(Logical AND)
128.17.75.0 // leaves
the network portion of the address
Table of Network Classes
Network Class | # Addresses
Available |
Structure | First Byte
Range |
Example | # Networks
Possible |
Percent
Assigned |
Class A | ~ 16 M | first byte fixed | 1 to 127 | 55 . x . x . x | 127 | 100% |
Class B | ~ 65 K | first two bytes fixed | 128 to 191 | 144. 89 . x . x. | ~16K | 80% |
Class C | 254 | first three bytes fixed | 192 to 233 | 200 .3 . 3 . 22 | ~2M | 30% |
Class D & E | reserved | ----------------- | 240 up | --------------- | ------ | ----- |
// What happened to 233 to 240?
tried a number( http://238.111.111.233/ )here
// and it returned this
error'(47) Address family not supported by protocol family'
Subnets
Each organization must assign the addresses it
has received to the computers on it's
network. Addresses are normally assigned so all
the computers on one local area
network have similar addresses. For instance
a college class B network might have
the Computer Science of 133.9.2.x while the Business
school might be on 133.9.3.x
and so on. Each of these LANs would be calleda
TCP/IP subnet.
To make them more comprehensible, IP addresses
more been given name aliases. This job
is done by the DNS,
the Domain Name Service. This
is a global distributed database.Each
organization on the internet maintains it's list
of machine addresses and domain names and
makes them accessible to the collective service.
Some machines in a sub-network have two IP addresses,
one locating it on it's own network,
along with a second IP address locating it on
another sub-network as well. This machine is then
able to route
or
act as a gateway
connections
between machines on either of the two networks.
All the sub-networks of the internet are interconnected
in this fashion allowing all the machine of
the internet to communicate with each other.
Java Client and Server
A client is a piece of software
which is able to open a communication stream with another piece
of software called a server. What
distinguishes the two is the server is normally always running,
'listening' or waiting to be contacted by a client while the client
is started as required and initiates
the connection with the server. (An alternate
arrangement can exist where the server is activated
by a client request for a connection.)
In TCP/IP versions of the Client/Server
both the client
and server have sockets which may
be used to connect the two pieces of software remotely
through a net connection.
In Java, a server uses an instance of the ServerSocket
class to 'listen for' and 'accept' requests
for connections from clients. The client uses a Socket
class
instance to connect to the server.
Because the client and server are normally run from their own dedicated
machines we often
think of each being the machine itself.
This notion is strengthened by the fact that we think
of our machines being assigned internet addresses and port numbers.
The addressing is really
assigned in software running on the machines and as such a client and
server can co-habitat on
the same machine. In fact, the socket evolved from early efforts to
allow
processes running
on the same machine to communicate with each
other.
Writing and testing clients and
servers in seperate (dos or unix ) processes running on the same computer
is convenient for
the developer. To run a client and a server
locally, the string literal "localhost"
is
used as
the domain name or, equivalently,
the specially assigned, four byte value, 127.0.0.1.
They
are used wherever sockets reference the
IP address.
// "localhost" is also called the loopback address
Connecting
When the client instantiates it's socket, a connection is created, to
the server, addressed in
the arguments provided to the Socket constructor,
(host and port number). The server socket
doesn't itself engage in a connection to the client. Instead, the
server spawns a new Socket
object as a return value from it's accept(
) method. (It isn't apparent but another synchronized
version of accept( ) is in-lined in the process.) This new Socket is
assigned a port number which
is shared with the client. The new socket is opened on the client's
IP address and port number
and the client-Server connection is complete. Both parties can then
create low-level, input/output
streams using the Socket class'
getInputStream(
)and
getOutputStream( ) methods.
Once
these streams are in place reading and writing can begin between the
connected parties.
Essential Elements of a Client
1) creation of a Socket object
2) open streams (optionally adding specialized secondary streams)
3) call read( )
& writes( ) on stream instances
to the protocol's specialization
4) close( ) streams
Essential Elements of a Server
1) creation of a ServerSocket
object
2) a listening loop containing the accept(
) method
3) adding stream(s) (optionally adding buffered and specialized secondary
streams)
4) call read( ) &
writes(
) on stream instances to the protocol's specialization
5) close( ) streams
A Simple Client and Server Sample
The Client
import java.io.*;
class Client{
Socket socket=new Socket("localhost", 7799); // 1. new Socket on localhost, port 7799 InputStream is = socket.getInputStream(
); //2.
open streams via factory methods
DataOutputStream dos = new
DataOutputStream(os); // layered
higher level streams
dos.writeUTF(toSend);
dos.flush( );
// 4. closing streams
|
The Server
import java.io.*; import java.net.*; class Server{
OutputStream
os= socket.getOutputStream();
s =dis.readUTF();
// 5. read & writes
dos.writeUTF(uppercase); dos.flush(
);
// 6. close streams
|
Protocols
A protocol defines a commonly understood rules
for communication, and may be based
on exchanging sets of characters which both parties
(the client and the server) understand.
A classic example is SMTP
or Standard Mail Transfer Protocol.TCP/IP
is
the Transfer
Control Protocol and Internet Protocol in combination.
HTTP
is
Hyper Text Transfer
Protocol
used in the targetting and transmission of 'web' pages. Another well
know protocol
is FTP
or File Transfer Protocol.
Well known protocols have well known ports associated
with them that will normally be defined as their
default setting.( i.e. port 80 is the well known
port of HTTP and 25 is that of SMTP). Protocols
can be created and it is often desirable to
do so to create proprietory communication schemes.
In java protocols can be conveniently
defined in interfaces that both the client and
server implement.
The java.net package
Following is a very brief summary of some of the
classes of Java's net package. A more
thorough abridgement version can be viewed at
Overview
of the Net Package. See the full
package in the Java Developer Kit's documentation.
Most of the following abreviated text
is from jdk1.2.2/docs/api/index.html
Some of the Classes
public final class
InetAddress extends Object implements
Serializable
encapsulates both the numerical IP address and
the domain name for that address.
public class Socket
extends
Object
Socket class constructors create stream sockets to connect to
specified port numbers
and IP addresses.
Socket(InetAddress address, int port)
Socket(String host, int port)
public class ServerSocket
extends Object
ServerSocket class is a server socket
implementation. A server socket waits for requests to
come in locally or over the network. It performs
some operation based on that request, and
then possibly returns a result to the requester.
ServerSocket's method
accept( ) listens for a
connection to be made to this socket and accepts it and returns a Socket
object
to interact
with the client.
public abstract class URLConnection
extends
Object
A large class whose forty-odd information retrieving and connection
methods enable acccessing
the attributes of a remote resource. It's methods include;
abstract void connect( ) Opens a communications link to
the resource referenced by this URL,
if such a connection has not already been established.
Object getContent( ) Retrieves the contents of this URL connection.
InputStream getInputStream( ) Returns an input stream that reads
from this open connection.
OutputStream getOutputStream( ) Returns an output stream that
writes to this connection.
Permission getPermission( ) Returns a permission object representing
the permission necessary
to make the connection represented by this object.
URL getURL( ) Returns the value of this URLConnection's URL
field.
static String guessContentTypeFromStream(InputStream is)
Tries to determine the type of an input stream based on the characters
at the beginning of the
input stream.
static void setContentHandlerFactory(ContentHandlerFactory fac)
Sets the ContentHandlerFactory of an application.
public class URLClassLoader
extends
SecureClassLoader
used to access an array of bytes via a URL reference a create a new
class in the running JVM
public class URLDecoder
extends
Object
URLDecoder class contains a utility method for
converting from a MIME format called
"x-www-form-urlencoded"
to a String. To convert to a String, each character is examined
in turn:
1) The ASCII characters 'a'
through 'z', 'A' through 'Z', and '0' through '9' remain the same.
2) The plus sign '+' is
converted into a space character ' '.
3) The remaining characters
are represented by 3-character strings which begin with the percent sign,
"%xy",
where xy is the two-digit hexadecimal representation of the lower 8-bits
of the character.
The method is, public static String decode(String s) throws Exception
public class URLEncoder
extends
Object
URLEncoder mirrors the function of the decoder class via it's solitary
method,
public static String encode(String s)
public final class
URL extends Object implements Serializable
Class URL represents a Uniform Resource Locator,
a pointer to a "resource" on the World
Wide Web. A resource can be something as simple as a file or a directory,
or it can be a
reference to a more complicated object, such as a query to a database
or to a search engine
It's constructors are;
URL(String spec)
Creates a URL object from the String representation.
URL(String protocol, String host, int port, String file)
Creates a URL object from the specified protocol, host, port number,
and file. Once the URL
instance is created, it's methods can return a lot of information about
the environment the URL
exists in. It also has the following connecting methods;
URLConnection openConnection( )
Returns a URLConnection object that represents a connection to the
remote object referred
to by the URL.
InputStream openStream( )
Opens a connection to this URL and returns an InputStream for reading
from that connection.
public abstract class URLStreamHandler extends Object
The abstract class URLStreamHandler is the common superclass for all
stream protocol
handlers. A stream protocol handler knows
how to make a connection for a
particular protocol type, such
as http, ftp,or
gopher.
In
most cases, an instance of a
URLStreamHandler subclass is not created directly by an application.
Rather, the first
time a protocol name is encountered when constructing
a URL, the appropriate
stream protocol handler is automatically loaded.
public final class
SocketPermission extends Permission implements
Serializable
This class represents access to a network via sockets. A SocketPermission
consists of a host
specification and a set of "actions" specifying ways to connect to
that host. The possible ways
to connect to the host are;
1) accept 2) connect 3) listen 4) resolve
The "listen" action is only meaningful when used with "localhost". The
"resolve" (resolve host/ip
name service lookups) action is implied when any of the other actions
are present. An example,
if the following permission is granted
p1 = new SocketPermission("puffin.eng.sun.com:7777", "connect,accept");
It allows that code to connect to port 7777 on puffin.eng.sun.com, and
to accept connections on
that port. Similarly, if the following permission:
p1 = new SocketPermission("puffin.eng.sun.com:7777",
"connect,accept");
p2 = new SocketPermission("localhost:1024-", "accept,connect,listen");
is granted to some code, it allows that code to accept connections on,
connect to, or listen on any
port between 1024 and 65535 on the local host.
Granting code permission to accept or make connections to remote hosts
may be dangerous
because malevolent code can then more easily transfer and share confidential
data among parties
who may not otherwise have access to the data.
Exception classes
BindException
ConnectException
MalformedURLException
NoRouteToHostException
ProtocolException
SocketException
UnknownHostException
UnknownServiceException
Interfaces
ContentHandlerFactory
FileNameMap
SocketImplFactory
SocketOptions
URLStreamHandlerFactory