<< Chapter < Page Chapter >> Page >
The purpose of this module is to introduce the student to the Socket class.

Table of contents

Preface

This module is one in a collection of modules designed for teaching INEW 2338 Advanced Java (Web) at Austin Community College in Austin, TX. More specifically, it is one in asub-collection of modules designed for teaching network programming in that course. The purpose of this module is to introduce the student to the Socket class.

Viewing tip

I recommend that you open another copy of this module in a separate browser window and use the following links to easily find and view the Figuresand Listings while you are reading about them.

Figures

  • Figure 1 . Successful daytime query.
  • Figure 2 . Output for a successful echo test.
  • Figure 3 . Daytime program output.
  • Figure 4 . Output from the simple browser program.

Listings

General background information

Sockets in Java come in at least three varieties that are implemented by the following Java classes

  • Socket
  • DatagramSocket
  • ServerSocket

The first two socket classes represent TCP and UDP communications respectively.

Generally, these two socket classes are used to implement both clients and servers, while the ServerSocket class is only used to implement servers.

This module will concentrate on the use of the Socket class. The DatagramSocket class will be covered a future module. In the meantime, you can read about the DatagramSocket class and other interesting topics in my earlier publications at:

In addition, you may find a great deal of useful information in my older publications that are accessible at Programming Oldies But Goodies .

A low-level mechanism

Socket programming provides a low-level mechanism by which you can connect two computers for the exchange of data. One of those is generally considered tobe the client while the other is considered to be the server .

The client initiates a connection with a server. Servers wait for a clients to initiate connections.

A mutually acceptable application protocol

The governing protocol will determine what happens after the connection is made. In order for two computers to communicate effectively, they must eachimplement some mutually acceptable application protocol.

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Object-oriented programming (oop) with java. OpenStax CNX. Jun 29, 2016 Download for free at https://legacy.cnx.org/content/col11441/1.201
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Object-oriented programming (oop) with java' conversation and receive update notifications?

Ask