JDK (Java Development Kit) Tutorials
Dr. Herong Yang, Version 5.00

What Is a Socket?

This section describes what is a socket - An concept represents one end-point of a two-way communication link between two programs running on the Internet network.

Socket: An concept represents one end-point of a two-way communication link between two programs running on the Internet network.

Internet Address: A unique number to identify each computer system on the Internet.

Port: A number representing an entry point of on a computer system on the Internet, where a two-way communication link can be established.

Local System: The computer system at this end of a two-way communication link.

Remote System: The computer system at the other end of a two-way communication link.

A two-way communication link on the Internet involves:

  • Two computer systems, each has its own Internet address.
  • A port number on each computer system that is used only by this communication link.
  • An application program on each computer system that uses this communication link.
  • A socket object created in the application program that represents this communication link.
  • The application program can use the socket as a logical input or output device to receive or send data from or to the application program running at the other end of the communication link.
  • The application program can also query the socket for information about the communication link, like: The Internet address and port number at this end of the communication link; The Internet address and port number at the other end of the communication link.

The follwing diagram illustrates how an application program can use a socket to talk with other application programs running on another computer system throught a two-way communication link on the Internet:

Computer System I                            Computer System II

       i/o       |Address a|    Internet    |Address b|       i/o
App. A<--->Socket|Port 1   |<-------------->|   Port 2|Socket<--->App. X

Last update: 2006.

Table of Contents

 About This JDK Tutorial Book

 Downloading and Installing JDK 1.3.1 on Windows

 Downloading and Installing JDK 1.4.1 on Windows

 Downloading and Installing JDK 1.5.0 on Windows

 Downloading and Installing JDK 1.6.2 on Windows

 Date, Time and Calendar Classes

 Date and Time Object and String Conversion

 Number Object and Numeric String Conversion

 Locales, Localization Methods and Resource Bundles

 Calling and Importing Classes Defined in Unnamed Packages

 HashSet, Vector, HashMap and Collection Classes

 Character Set Encoding Classes and Methods

 Character Set Encoding Maps

 Encoding Conversion Programs for Encoded Text Files

Socket Network Communication

What Is a Socket?

 Establishing a Socket Communication Link

 ReverseEchoer.java - A Simple Server Socket Application

 SocketClient.java - A Simple Client Socket Application

 ReverseEchoServer.java - A Multi-Connection Socket Server

 Binding Sockets to Specific Ports

 Datagram Network Communication

 DOM (Document Object Model) - API for XML Files

 SAX (Simple API for XML)

 DTD (Document Type Definition) - XML Validation

 XSD (XML Schema Definition) - XML Validation

 XSL (Extensible Stylesheet Language)

 Message Digest Algorithm Implementations in JDK

 Private key and Public Key Pair Generation

 PKCS#8/X.509 Private/Public Encoding Standards

 Digital Signature Algorithm and Sample Program

 "keytool" Commands and "keystore" Files

 KeyStore and Certificate Classes

 Secret Key Generation and Management

 Cipher - Secret Key Encryption and Decryption

 The SSL (Secure Socket Layer) Protocol

 SSL Socket Communication Testing Programs

 SSL Client Authentication

 HTTPS (Hypertext Transfer Protocol Secure)

 References

 PDF Printing Version

Dr. Herong Yang, updated in 2008
What Is a Socket?