Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Networking in Java 
 

In this section we are exploring the java.net package which provides the support for networking in java with a generic style.

 

Networking in Java

                         

In this section we are exploring the java.net package which provides the support for networking in java with a generic style. All the java classes for developing a network program are defined in the java.net package. 
                                                   
Here we illustrate an example in which a client sends a request (lets say the request is..
"POST/index.html  HTTP/1.0\\n\\n" ) to the server for a file named index.html and as the server establishes a connection successfully, it gets the index.html file and sends it to the client.

Server

Client

Listens to port 8080. Connects to port 8080.
Accepts the connection. Writes "POST/index.html HTTP/1.0\\n\\n".
Reads up until it gets the second end-of line (\\n).
Sees that POST is a known command and that HTTP/1.0 is a valid protocol version.
Reads a local file called /index.html.
Writes "HTTP/1.0 8080 OK\\n\\n". "8080" means "here comes the file."

Copies the contents of the file into the socket.

Reads the contents of the file and displays it.

The above process is an actual transaction via which a client and a server talk with each other. Every computer on a network has an address. It is called an Internet address ( IP Address) it is a 12 digit number that uniquely identifies each computer on the Network. There are 32 bits in an IP address having a sequence of four numbers between 0 and 255 separated by dots  (.).  
                              
However it is a very cumbersome process to remember the computers on the network through their IP address values so DNS is there to help you out. It has devised a string format to identify an IP address that avoids the user to track so many numbers (IPs) over a network, it is also known as Domain Naming Service (DNS).

                            
Now lets quickly move on to the networking part of java and take a look at how it relates to all of these networking concepts. In Java we can build I/O objects across the network by extending the I/O interface. Java supports most of the networking  protocols e.g. TCP and UDP protocol families, TCP is used for reliable stream-based I/O across the network and UDP supports the point-to-point datagram-oriented model.
                  
All the java networking classes and interfaces are contained in the java.net package, it is given below:

Authenticator JarURLConnection SocketPermission
ContentHandler MulticastSocket URL
DatagramPacket NetPermission URLClassLoader
DatagramSocket

PasswordAuthentication

URLConnection
DatagramSocketImpl ServerSocket URLDecoder
HttpURLConnection Socket URLEncoder
InetAddress SocketImpl

URLStreamHandler

Including all above the package's interfaces of the java.net are as under :

ContentHandlerFactory SocketImplFactory
URLStreamHandlerFactory FileNameMap
SocketOptions

       
Apart from all of this the address is the fundamental part in sending mail, or establishing a connection across the Internet. In java the InetAddress class is used to encapsulate both the numerical IP address and the domain name for that address. The InetAddress class has no visible constructors that is why, to create an InetAddress object, we have to use one of the available factory methods like getLocalHost( ), getByName( ), and getAllByName( ) can be used.

    

                         

» View all related tutorials
Related Tags: c com forms server orm form network socket io sed request return opera ai for work wait to base pos

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

2 comments so far (
post your own) View All Comments Latest 10 Comments:

Hi, gud day. kindly help me in java. I want to print java form, and connect may application to a network printer attached to other computer. can please help me for the script. thanks ^_^

Posted by frank on Sunday, 12.21.08 @ 21:40pm | #83019

iam studing mca final year , ican not find j2me tutorial at roseindia only please send address to my mail .

Posted by jagadeesh on Thursday, 12.27.07 @ 09:50am | #43914

Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.