Professional Documents
Culture Documents
Module Objectives
At the end of this module, participants will be
able to:
Define the basic concepts about TCP/IP
networking.
Establish a network connection.
Send data across the network.
Client App
3333
80
Client App
Server IP: 192.168.0.2
80
Client App
9999
Client App
Individual nodes in a
network are identified by
an IP address.
Network connections
created by applications
running on a single
computer on the network
can be further identified by
an assigned port number.
The data is transferred
through streams.
Establishing a Connection
For TCP connections, the URL, URLConnection, Socket, and
ServerSocket classes are used.
For UDP connections, the DatagramPacket, DatagramSocket,
and MulticastSocket are used.
Using URLs
A URL is a Uniform Resource Locator and is used as a
reference to any resource on the Internet.
A URL is composed of a protocol and a resource identifier.
The protocol refers to a set of rules governing the format of
messages that are exchanged between computers.
The resource identifier indicates where the resource is to be
found.
Protocol
Resource Name
URL
http
www.accenture.com
http://www.accenture.com
Using Sockets
Sockets represent the end points between two applications in a
network.
When a socket is created it is bound to an IP address and a port
number.
One end point acts as the server that waits for connections
(represented by ServerSocket class).
One or more end points acts as a client and that seeks to
connect to a server (represented by Socket class).
** Refer to the ServerSample.java and ClientSample.java sample code
10
Creating a ServerSocket
Instantiate a ServerSocket instance and bind it to a specific port
number.
ServerSocket server = new ServerSocket(9999);
11
12
13
Activity
1)
2)
3)