Week 6
Network Programming
Learning Outcomes
• Describe the key components of Network Protocols.
• Describe network management and protection techniques.
• Describe socket programming methods.
• Describe Inter-process communication systems.
Week 6: Network Programming
Background
There are many issues that arise when doing network
programming which do not appear when doing single
program applications. However, JAVA makes networking
applications simple due to the easy-to-use libraries. In general,
applications that have components running on different
machines are known as distributed applications ... and usually
they consist of client/server relationships..
Week 6: Network Programming
Background
Network Programming involves writing programs
that communicate with other programs across a
computer network.
A server is an application that provides a "service"
to various clients who request the service.
Week 6: Network Programming
Background
There are many client/server scenarios in real life:
• Bank tellers (server) provide a service for the account
owners (client)
• Waitresses (server) provide a service for customers (client)
• Travel agents (server) provide a service for people wishing
to go on vacation (client)
Week 6: Network Programming
Background
In some cases, servers themselves may become clients at various
times example is the travel agents will become clients when they
phone the airline to make a reservation or contact a hotel to book a
room.
In the general networking scenario, everybody can either be a client
or a server at any time. This is known as peer-to-peer computing. In
terms of writing java applications it is similar to having many
applications communicating among one another.
Week 6: Network Programming
Reading Files from the Internet
A Uniform Resource Locator (i.e., URL) is a reference (or address)
to a resource over a network (e.g., on the Internet).
So, a URL can be used to represent the "location" of a webpage or
web-based application. A URL is really just a String that represents
the name of a resource ... which can be files, databases, applications,
etc. A resource name consists of a host machine name, filename, port
number, and other information.
Week 6: Network Programming
Reading Files from the Internet
A URL resource name may generally contain:
• A Host Name - The name of the machine on which the resource
lives. http://www.apple.com:80/ipad/index.html
• A Port # (optional) - The port number to which to connect.
http://www.apple.com:80/ipad/index.html
• A Filename - The pathname to the file on the machine.
http://www.apple.com:80/ipad/index.html
Week 6: Network Programming
Client/Server Communications
A server is any application that provides a service and
allows clients to communicate with it.
A client is any application that requests a service from a
server.
Week 6: Network Programming
Client/Server Communications
The TCP protocol, mentioned earlier, provides reliable point-to-point
communication. Using TCP the client and server must establish a
connection in order to communicate.
To do this, each program binds a socket to its end of the connection. A
socket is one endpoint of a two way communication link between 2
programs running on the network. A socket is bound to a port number
so that the TCP layer can identify the application to which the data is
to be sent. It is similar to the idea of plugging the two together with a
cable.
Week 6: Network Programming
Datagram Sockets
The same client-server application, but by now using
DatagramSockets and DatagramPackets. Once again, the server will
be in a infinite loop accepting messages, although there will be no
direct socket connection to the client.
Each message is sent as a packet. Each packet contains:
• the data of the message (i.e., the message itself)
• the length of the message (i.e., the number of bytes)
• the address of the sender (as an InetAddress)
• the port of the sender
References and Materials
Books and Journals
1. Unix Network Programming (2016) The Sockets Networking API, Volumes 1, by W Richard Stevens, Bill Fenner,
Andrew M. Rudoff, published by Addison-Wesley (UNP)
2. Information Storage and Management: Storing, Managing, and Protecting Digital Information in Classic,
Virtualized, and Cloud Environments, Second Edition, EMC Education Services, 2012
Online Supplementary Reading Materials
1. Network Programming: http://www.cse.sc.edu/~wyxu/515Fall08/csce515.html
2. https://www.slideshare.net/vijipriyacse/ipt-chapter-5
Online Instructional Videos
1. https://www.youtube.com/watch?v=xOk9-ZwW6-o
Thank You!