Network Programming Introduction
Java supports Network Programming to communicate with other machines.
s start with Network Programming Introduction.
Network Programming Introduction:
As we all know that Computer Network means a group of computers connect with each other via some medium and transfer data between them as and when require.
Java supports Network Programming so we can make such program in which the machines connected in network will send and receive data from other machine in the network by programming.
The first and simple logic to send or receive any kind of data or message is we must have the address of receiver or sender. So when a computer needs to communicate with another computer, its require the other computer’s address.
Java networking programming supports the concept of socket. A socket identifies an endpoint in a network. The socket communication takes place via a protocol.
The Internet Protocol is a lower-level, connection less (means there is no continuing connection between the end points) protocol for delivering the data into small packets from one computer (address) to another computer (address) across the network (Internet). It does not guarantee to deliver sent packets to the destination.
The most widely use a version of IP today is IPv4, uses a 32 bit value to represent an address which are organized into four 8-bits chunks. However new addressing scheme called IPv6, uses a 128 bit value to represent an address which are organized into four 16-bits chunks. The main advantage of IPv6 is that it supports much larger address space than does IPv4. An IP (Internet Protocol) address uniquely identifies the computer on the network.
IP addresses are written in a notation using numbers separated by dots is called dotted-decimal notation. There are four 8 bits value between 0 and 255 are available in each IP address such as 127.0.0.1 means local-host, 192.168.0.3 etc.
s not an easy to remember because of so many numbers, they are often mapped to meaningful names called domain names such as mail.google.com There is a server on Internet who is translate the host names into IP addresses is called DNS (Domain Name Server).
NOTE: Internet is the global network of millions of computer and the any computer may connect the Internet through LAN (Local Area Network), Cable Modem, ISP (Internet Service Provider) using dialup.
When a user pass the URL like learnermode.com in the web-browser from any computer, it first ask to DNS to translate this domain name into the numeric IP address and then sends the request to this IP address. This enables users to work with domain names, but the internet operates on IP addresses.
Here in learnermode.com the “com” domain is reserved for commercial sites; then “learnermode” is the company name.
The Higher-level protocol used in with the IP are TCP (Transmission Control Protocol) and UDP (User Datagram Protocol).
The TCP enables two host to make a connection and exchange the stream of data, so its called Stream-based communication. TCP guarantees delivery of data and also guarantees that streams of data will be delivered in the same order in which they are sent. The TCP can detect the lost of transmission and so resubmit them and hence the transmissions are lossless and reliable.
The UDP is a standard, directly to support fast, connectionless host-to-host datagram oriented model that is used over the IP and exchange the packet of data so it`s called packet-based communication. The UDP cannot guarantee lossless transmission.
JAVA supports both TCP and UDP protocol families.