Networking
Networking
IP is Internet Protocol. It is the network protocol which is used to send information from one computer to another
over the network over the internet in the form of packets.
A port is an 16-bit address within a computer.Ports for some common Internet Application protocols.
59.What is hypertext?.
Sockets are endpoints of Internet Communication.They are associated with a host address and a port
address.Clients create client sockets and connect them to server sockets.
MIME(Multipurpose Internet Mail Extension) is a general method by which the content of different types of
Internet objects can be identified.
Networking (java.net)
Creating a URL
try {
// With components.
“http://hostname:80/index.html”);
} catch (MalformedURLException e) {
Parsing a URL
try {
} catch (MalformedURLException e) {
try {
new InputStreamReader(url.openStream()));
String str;
process(str);
}
in.close();
} catch (MalformedURLException e) {
} catch (IOException e) {
Resolving a Hostname
} catch (IOException e) {
try {
} catch (IOException e) {
try {
new InputStreamReader(socket.getInputStream()));
String str;
process(str);
rd.close();
} catch (IOException e) {
try {
new OutputStreamWriter(socket.getOutputStream()));
wr.write(“aString”);
wr.flush();
} catch (IOException e) {
Sending a Datagram
try {
socket.send(request);
} catch (SocketException e) {
} catch (IOException e) {
}
}
Receiving a Datagram
try {
inbuf, inbuf.length);
socket.receive(packet);
} catch (SocketException e) {
} catch (IOException e) {
try {
group = InetAddress.getByName(groupName);
msocket.joinGroup(group);
} catch (IOException e) {
}
}
byte[] inbuf) {
try {
DatagramPacket packet = new DatagramPacket(
inbuf, inbuf.length);
msocket.receive(packet);
} catch (IOException e) {
}
}
try {
“228.1.2.3”);
socket.send(packet);
} catch (SocketException e) {
} catch (IOException e) {