- Java Programming Basics
- Java Tutorial
- Java Overview
- Java Environment Setup
- Java Program Structure
- Java Basic Syntax
- Java First Program
- Java Constants
- Java Separators
- Java Keywords
- Java Data Types
- Java Data Types
- Java Integers
- Java Floating Point
- Java Characters
- Java Booleans
- Java Numbers
- Java Programming Variables
- Java Variables
- Java Variable Types
- Java Variable Scope
- Java Type Conversion
- Java Type Casting
- Java Auto Type Promotion
- Java Type Promotion Rules
- Java Programming Arrays
- Java Arrays
- Java One Dimensional Array
- Java Multidimensional Array
- Java Programming Operators
- Java Operators
- Java Arithmetic Operators
- Java Increment Decrement
- Java Bitwise Operators
- Java Left Shift
- Java Right Shift
- Java Relational Operators
- Java Boolean Logical Operators
- Java Ternary(?) Operator
- Java Operator Precedence
- Java Control Statements
- Java Decision Making
- Java if if-else if-else-if
- Java switch Statement
- Java Loops
- Java while Loop
- Java do-while Loop
- Java for Loop
- Java for-each Loop
- Java Nested Loops
- Java break Statement
- Java continue Statement
- Java Class Object Method
- Java Classes and Objects
- Java Class
- Java Object
- Java new Operator
- Java Methods
- Java Constructors
- Java this Keyword
- Java Stack
- Java Overloading Recursion
- Java Method Overloading
- Java Constructor Overloading
- Java Object as Parameter
- Java Call by Value Reference
- Java Returning Objects
- Java Recursion
- Java Modifier Types
- Java Encapsulate Poly String
- Java Encapsulation
- Java Polymorphism
- Java Nested Inner Class
- Java Strings
- Java Command Line Arguments
- Java Variable Length Arguments
- Java Inheritance Abstraction
- Java Inheritance
- Java super Superclass
- Java Multilevel Hierarchy
- Java Method Overriding
- Java Abstraction
- Java Packages Interfaces
- Java Packages
- Java Access Protection
- Java Import Statement
- Java Interfaces
- Java Programming Exceptions
- Java Exception Handling
- Java try catch
- Java throw throws
- Java finally Block
- Java Built In Exceptions
- Java Exception Subclasses
- Java Chained Exceptions
- Java Multithreading
- Java Multithreading
- Java Thread Model
- Java Main Thread
- Java Create Thread
- Java Thread Priorities
- Java Synchronization
- Java Inter Thread Communication
- Java Suspend Resume Stop Thread
- Java Get Thread State
- Java Enum Autobox Annotation
- Java Enumerations
- Java Type Wrappers
- Java Autoboxing
- Java Annotation
- Java Marker Annotations
- Java Single Member Annotation
- Java Built In Annotations
- Java Type Annotations
- Java Repeating Annotations
- Java Data File Handling
- Java Files I/O
- Java Streams
- Java Read Console Input
- Java Write Console Output
- Java PrintWriter Class
- Java Read Write Files
- Java Automatically Close File
- Java Programming Advance
- Java Date and Time
- Java Regular Expressions
- Java Collections Framework
- Java Generics
- Java Data Structures
- Java Network Programming
- Java Serialization
- Java Send Email
- Java Applet Basics
- Java Documentation
- Java Programming Examples
- Java Programming Examples
Java Networking
At the core of Java's networking support is the thought of a socket. A socket identifies an endpoint in a network. The socket model was part of the 4.2BSD Berkeley UNIX release in the early 1980s. Because of this, the term Berkeley socket can also used.
Sockets
Sockets are at the foundation of modern networking because a socket allows a single computer to server many different clients at once, as well as to server many different types of information. This is accomplished through the use of a port, which is numbered socket on a particular machine. A server process is said to "listen" to a port before a client connects to it.
Server
A server is granted to accept multiple clients connected to the same port number, although each session is unique. To manage multiple clients connection, a server process must be multithreaded or have some other signifies of multiplexing the simultaneous I/O.
Socket Communication
Socket communication takes place via a protocol.
Protocol
Here are the three levels of protocols:
- Internet Protocol (IP)
- Transmission Control Protocol (TCP)
- User Datagram Protocol (UDP)
Let's discuss briefly about these three levels of protocol one by one.
Internet Protocol (IP)
Internet Protocol (IP) is a low-level routing protocol which breaks data into small packets and sends them to an address across a network, which doesn't guarantee to deliver the said packets to the destination.
Transmission Control Protocol (TCP)
Transmission Control Protocol (TCP) is a higher-level protocol which manages to robustly string together these packets, sorting and retransmitting them as necessary to dependably transmit data.
User Datagram Protocol (UDP)
A third protocol named User Datagram Protocol (UDP), sits next to TCP and can be used directly to support fast, connection-less, undependable transport of packets.
Port
Once a connection has be established, a higher-level protocol ensures, which is dependent on which port you are using. TCP/IP reserves the lower 1,024 ports for specific protocols. Many of these will seem known to you if you have spent any time surfing the Internet. Port number
- 21 is for FTP
- 23 is for Telnet
- 25 is for email
- 43 is for whois
- 80 is for HTTP
- 119 is for netnews
and the list goes on. It is up to each protocol to specify how a client should interact with the port.
For instance, HTTP is the protocol that web browsers and servers use to transfer hypertext pages and images. It is just simple protocol for a basic page-browsing web server.
Here is how it works:
When a client requests a file from an HTTP server, an action known as a hit, it just sends the name of the file in a special format to a
predefined port and reads back the file's contents. The server also responds with a status code to tell the client whether or not the request can be
achieved and why.
Internet Address - IPv4
A key component of the Internet is the address. Every computer on the Internet has one. An Internet address is simply a number that uniquely identifies each computer on the Net. Originally, all the Internet address consisted of 32-bit values that organized as four 8-bit values. This address type was specified by IPv4 (Internet Protocol, version 4).
Internet Address - IPv6
On the other hand, a new addressing scheme, called IPv6 (Internet Protocol, version 6) has come into play. The IPv6 uses a 128-bit value to represent an address that organized into eight 16-bit chunks
Although there are several reasons for advantages to IPv6, the main one is that it supports a much larger address space than does IPv4. Fortunately, when using Java, you won't generally need to worry about whether IPv4 or IPv6 addresses are used as Java handles the details for you.
Just as the number of an IP address describes a network hierarchy, and the name of an Internet address, called its domain name, descries a machine's location in a name space. For instance, jobails.com is in the COM top-level domain (that reserved for the U.S. commercial sites); it is called fresherearth, and www determines the server for web requests. And an Internet domain name is simply mapped to an IP address by Domain Naming Service (DNS). This enables users to work with the domain names, but the Internet operates on IP address.
« Previous Tutorial Next Tutorial »