Powered by Blogger.

Friday 30 January 2015

Java Networking

No comments :
Basics Networking: Computers Running on the Internet Communication to each other using either the TCP OR UDP.Java Network Programming:Network Programming refers to writing Programs that execute across multiple devices in which the devices are all connected to each using a network. The Networking Classes and Interfaces available in java.net package.
Application:

Protocol NamePort Number
Hypertext Transfer Protocol (HTTP)80
File Transfer Protocol (FTP)21
TELecommunication NETwork (Telnet)23
E-mail Protocol43
Network News Transfer Protocol (NNTP)119

Transport:
When you have to write Network Programs That is used to TCP (Transmission Control Protocol) or UDP (User Datagram Protocol). TCP: TCP provides a Point-to -Point Channel For applications that require reliable Communication. It is higher-level Protocol that Manages to robustly String together these Packets, Sorting and retransmitting them as necessary to reliably transmit data. UDP: UDP Sends independent packets of data, called datagrams, from one Application to other.
Network IP:
An IP (Internet Protocol) address describe a network hierarchy. All Internet address Consisted of 32-bit Values, Organized as four 8-bit values.This address Type was specified by IPv4 (Internet Protocol, Version 4) however, a new addressing scheme, called IPv6 (Internet Protocol, Version 6) has come in to play.IPv6 uses a 128-bit value to represent an address, organized into eight 16-bit chunks. Although there are several reasons for and advantages to IPv6, the main one is that it supports a much larger address space than does IPv4.
InetAddress:
The InetAddress class is used to encapsulate both the numerical IP address and the domain name for the address. InetAddress can handle both IPv4 and IPv6 address.
Factory Methods:
The InetAddress class has no visible constructors. To InetAddress object, you have to use one of the available factory methods.
There commonly used InetAddress factory methods are shown here.



The getLocalHost() method simply returns the InetAttress object that represents the localhost. The getByName() method returns an InetAddress for a host name passed to it. if these methods are unable to resolve the host name, they thow an UnknownHostException. getAllByName() factory method returns an array of InetAddress that represent all of the address that a particular name resolve to. It will also throws an UnknownHostException if it can't resolve the name to at least one address. InetAddress also includes the factory method getByAddress(), which takes an IP Address and returns an InetAddress object.
Example of First InetAddress :



Out Put:
                                                           Manoj-PC/100.118.88.245 
                                                           www.HerbSchildt.com/216.92.65.4 
                                                           www.nba.com/223.196.82.72 
                                                           www.nba.com/223.196.82.73 
            

No comments :

Post a Comment

Please Write a Message for Programming or something Related issues.