Vous êtes sur la page 1sur 5

Networking with java model1

part A 2marks
1.Distinguish host and node.
Each machine on a network is called a node. Most nodes are computers, but printe
rs, routers, bridges, gateways, dumb terminals, and Coca-Cola machines can also b
e nodes .Every network node has an address, a series of bytes that uniquely iden
tify it.The word host is a node that is a general-purpose computer.
2.Define ethernet addresses.
Ethernet addresses are attached to the physical Ethernet hardware. Manufacturers
of Ethernet hardware use pre-assigned manufacturer codes to make sure there are
no conflicts between the addresses in their hardware and the addresses of other
manufacturer s hardware. Each manufacturer is responsible for making sure it does
n t ship two Ethernet cards with the same address
3. Give four layers of TCP/IP network.
Hosts to network, Internet, transport, Application are four layers.
4. Distinguish between URN and URL.
There are two types of URIs: Uniform Resource Locators (URLs) and Uniform Resour
ce Names (URNs). A URL is a pointer to a particular resource on the Internet at
a particular location. For example, http://www.oreilly.com/catalog/javanp3/ is o
ne of several URLs for the book Java Network Programming. A URN is a name for a
particular resource but without reference to a particular location. For instance
, urn:isbn: 1565928709 is a URN referring to the same book. As this example show
s, URNs,unlike URLs, are not limited to Internet resources.
5. What is relative URL?
For example, suppose that while browsing http://www.ibiblio.org/javafaq/javatuto
rial.html you click on this hyperlink:
<a href="javafaq.html">
The browser cuts javatutorial.html off the end of http://www.ibiblio.org/javafaq
/javatutorial.html to get http://www.ibiblio.org/javafaq/. Then it attaches java
faq.html onto the end of http://www.ibiblio.org/javafaq/ to get http://www.ibib
lio.org/javafaq/javafaq.html. Finally, it loads that document.If the relative li
nk begins with a /, then it is relative to the document root instead of relative
to the current file. Thus, if you click on the following link while browsing ht
tp://www.ibiblio.org/javafaq/javatutorial.html:<a href="/boutell/faq/www_faq.htm
l"> the browser would throw away /javafaq/javatutorial.html and attach /boutell/
faq/ www_faq.html to the end of http://www.ibiblio.org to get http://www.ibiblio
.org/boutell/faq/www_faq.html.
6. What IS HTTP?
HTTP is the standard protocol for communication between web browsers and web
servers. HTTP specifies how a client and server establish a connection, how the
client requests data from the server, how the server responds to that request, a
nd finally, how the connection is closed. HTTP connections use the TCP/IP protoc
ol for data transfer. For each request from client to server, there is a sequenc
e of four steps:
Making the connection :The client establishes a TCP conn
ection to the server on port 80, by default; other ports may be specified in the
URL.
Making a request: The client sends a message to
the server requesting the page at a specified URL.The format of this request is
typically something like: GET /index.html HTTP/1.0
7. What is output stream?
Output Streams Java s basic output class is java.io.OutputStream:
public abstract class OutputStream This class provides the fundamental meth
ods needed to write data. These are:

public abstract void write(int b) throws IOException


public void write(byte[] data) throws IOException
public void write(byte[] data, int offset, int length) throws IOException
public void flush( ) throws IOException
public void close( ) throws IOException
8. What is input stream?
Input Streams
Java s basic input class is java.io.InputStream:
public abstract class InputStream
This class provides the fundamental methods needed to read data as raw
bytes.
These are:
public abstract int read( ) throws IOException
public int read(byte[] input) throws IOException
public int read(byte[] input, int offset, int length) throws IOException
public long skip(long n) throws IOException
public int available( ) throws IOException
public void close( ) throws IOException
9. Give two methods of creating threads.
To give a thread something to do, you either subclass the Thread class and overr
ide its run( ) method, or implement the Runnable interface and pass the Runnable
object to the Thread constructor.
10. What is deadlock?
Deadlock occurs when two threads need exclusive access to the same set of resour
ces and each thread holds the lock on a different subset of those resources.
Networking with java model2
2 marks
1.Where Inet class is used?
It is used by most of the other networking classes, including Socket, ServerSock
et, URL, DatagramSocket, DatagramPacket, and more. Generally, it includes both a
hostname and an IP address.
2.What is Security issue?
Untrusted host not allowed to do DNS lookup.
3.What is testing reachability?
Testing Reachability // Java 1.5 Java 1.5 adds two new methods to the InetAddres
s class that enable applications to test whether a particular node is reachable
from the current host; that is, whether a network connection can be made. Connec
tions can be blocked for many reasons, including firewalls, proxy servers, misbe
having routers, and broken cables, or simply because the remote host is not turn
ed on when you try to connect. The isReachable( ) methods allow you to test the
connection:
public boolean isReachable(int timeout) throws IOExcep

tion
public boolean isReachable(NetworkInterface i
nterface, int ttl, int timeout) throws IOException
4.How many protocols are in HotJava?
14 protocols are there (8 standard protocols, 3 custom protocols for va
rious Java APIs, and 4 undocumented protocols used internally by HotJava).
5.What are 5 pieces of URL?
URLs are composed of five pieces:
The scheme, also known as the protocol
The authority
The path
The query string
For example, given the URL http://www.ibiblio.org/javafaq/bo
oks/jnp/index.html?isbn=1565922069#toc, the scheme is http, the authority is www
.ibiblio.org, the path is /javafaq/books/jnp/index.html, the fragment identifier
is toc, and the query string is isbn=1565922069.
6.What are the seven functions sockets can pe
rform?
A socket is a connection between two hosts. It can perform seven basic functions
Connect to a remote machine
Send data
Receive data
Close a connection
Bind to a port
Listen for incoming data
Accept connections from remote machines on the bound port
7.What are the four options in the class of service?
Class of service
0x02: Low cost
0x04: High reliability
0x08: Maximum throughput
0x10: Minimum delay
8.Give the use of client tester program.
Example 10-5 is a program called ClientTester that runs on a port specified on t
he command line, shows all data sent by the client, and allows you to send a res
ponse to the client by typing it on the command line. For example, you can use t
his program to see the commands that Internet Explorer sends to a server.
9.What is secure socket?
Java Secure Sockets Extension (JSSE). Although JSSE is now part of the standard
distribution of the JDK, it is still hobbled by design decisions made to support
earlier, less liberal export control regulations, and it is therefore less simp

le and easy to use than it could or should be. Nonetheless, JSSE can secure netw
ork communications using the Secure Sockets Layer (SSL) Version 3 and Transport
Layer Security (TLS) protocols and their associated algorithms. SSL is a securit
y protocol that enables web browsers to talk to web servers using various levels
of confidentiality and authentication.
10.What is the use of channel?
Channels - Channels move blocks of data into and out of buffers to and fro
m various I/O sources such as files, sockets, datagrams, and so forth.
Networking with java model3
2marks questions
1. What are the two clssses for sending UDP datagrams?
DatagramPacket and DatagramSocket are the two classes. To send data, data is put
in DatagramPocket and is sent using a DatagramSocket.
2. What is the maximum IPV4 datagram packet size? What is the maximum IPV6 datag
ram packet size? Whjat makes datagram packet size limited to 8192 bytes?
The theoretical limit for an IPv4 datagram is 65,507 bytes of data, and a Datagr
amPacket with a 65,507-byte buffer can
receive any possible IPv4 datagram without losing data. IPv6 datagrams raise the
theoretical limit to 65,536 bytes.In fact, many operating systems don t support U
DP datagrams with more than 8K of data and either truncate, split, or discard la
rger datagrams.
3.What is a Multicasting?
Multicasting sends data from one host to many different hosts, but not to everyo
ne; the data only goes to clients that have expressed an interest by joining a p
articular multicast group.(like public meeting - people who can hear hear.)
4. What is the range of multicast address?
Multicast addresses are IP addresses in the range 224.0.0.0 to 239.255.255.255.
All addresses in this range have the binary digits 1110 as their first four bits
are called Class D addresses.
5. What is URLConnection class?
URLConnection is an abstract class that represents an active connection to a res
ource specified by a URL.You can use a URLConnection to download binary files. F
inally, a URLConnection lets you send data back to a web server with POST or PUT
and use other HTTP request methods.
6. What protocols java does not support out of box?
standard protocols such as finger, whois, or NTP Java doesn t support out of the
box
7. What is the default port for DayTime protocol handler? What data it returns?
DEFAULT_PORT = 13;The sample data it returns is Fri Oct 29 14:32:07 1999.
8. What is content handler?
content handler is an instance of a subclass of java.net.ContentHandler:This cla
ss knows how to take a URLConnection and a MIME type and turn the data coming fr
om the URLConnection into a Java object of an appropriate type. Thus, a content
handler allows a program to understand new kinds of data.
9.What is remote method invocation?
RMI lets Java objects on different hosts communicate with each other in a way th
at s similar to how objects running in the same virtual machine communicate with e
ach
other: by calling methods in objects. A remote object lives on a server. Each re
mote object implements a remote interface that specifies which of its methods ca
n be
invoked by clients. Clients invoke the methods of the remote object almost exact
ly as they invoke local methods.
10. What is JavaMail API?
The JavaMail API is a fairly high-level representation of the basicc omponents o
f any email system. The components are represented by abstract classes in the ja
vax.mail
package. For instance, the abstract class javax.mail.Message represents an email
message. It declares abstract methods to get and set various kinds of envelope

information for the message, such as the sender and addressee, the date sent, an
d the subject of the message. The abstract class javax.mail.Folder represents a
message
container. It declares abstract methods to get messages from a folder, move mess
ages between folders, and delete messages from a folder.These classes are all ab
stract because they don t make many assumptions about how the email is stored or t
ransferred between machines. For instance, they do not assume that messages are
sent using SMTP or that they re structured as specified in RFC 822.

Vous aimerez peut-être aussi