[go: up one dir, main page]

0% found this document useful (0 votes)
23 views12 pages

Chapter 5

This document contains network-related topics, which is prepared for class presentation.

Uploaded by

mazu1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views12 pages

Chapter 5

This document contains network-related topics, which is prepared for class presentation.

Uploaded by

mazu1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Client and server computing

Web technology is the establishment and use of mechanisms that make it


possible for different computers and devices to communicate and share
resources. Web technologies are infrastructural building blocks of any
effective computer network.
Web technologies are infrastructural building blocks of any effective
computer network: local area network, metropolitan area network or a wide
area network, such as the Internet.
Communication on a computer could never be as effective as they are
without the plethora of Web technologies in existence.

Activity 6.1

 How client and server communicate each other?


 Discuss on client, standalone and server computer?
 Discuss on web technologies?

What is the use of Web technology?

A variety of Web technology is vital to the function and success of many


businesses.
→These include online appointment scheduling programs, websites and a
way for customers to chat with representatives. Also, Web technology makes
it possible for businesses to collect data on their customers to further
customize their services.

How web technologies are developed?

By using Markup Languages:

→Markup languages like HTML, CSS, and XML are part of Web technology.
→These languages tell computers in text how to format, layout and style
Web pages and programs.
→Two types of markup languages include procedural markup and descriptive
markup. Additional types of languages include CGI and HTTP.

Programming Languages

Programming languages include Perl, C#, Java and Visual Basic .NET. These
languages are used by Web developers to create websites and applications.
Each language has pros and cons, and most developers know several
different types to help them achieve their goals.
HTML: The Foundation of any Web Site. HTML (HyperText Mark-up
Language) is the glue that holds together every web site. Like building a
house, you always build a strong foundation first. For any site, HTML is that
foundation. HTML is an open-source language (i.e. not owned by anyone),
which is easy to learn, and requires no fancy (or expensive!) packages to
start using it.
All you need is something to type with, such as Windows Notepad, and a lot
of time and patience.
HTML works on a ‘tag’ system, where each tag effects the content placed
within that tag;
<TAG>What the tag effects</TAG>.
CSS(Cascading Style Sheets)
→CSS is a relatively new language, designed to expand upon the limited
style properties of HTML.
→Easy to learn and implement, CSS is an excellent way to control the style of
your site, such as text styles like size, color, and font.
→CSS may also be placed inside the HTML page or in separate files.

6.2. Server-Side Programs


Data Communication and Computer Networks (ITec2102) CHAPTER SIX: CLIENT SERVER

COMPUTING 6.2. Server-Side Programs

Throughout this course, we have been creating HTML with a text editor and
saving .html files.
When these are put on a web server, they are then sent as-is to web
browsers. In this case, the job of the web server is very simple: find the file
and send it out.
We have been able to modify the HTML page with code we have written, but
that was all JavaScript code that runs in the web browser. There was never
any change in the HTML sent from the server to the browser.
But if you think about many web sites you visit, this method of creating web
pages can’t be the whole story. On Facebook, your news feed changes each
time you load it: nobody is sitting there typing HTML to update it for you.
When you search on Google, you might be searching for something nobody
has ever searched for before, so there’s no way the result can be pre-
prepared.
For these sites (and many others), the HTML that is sent from the server to
your browser must be generated when you request it. There is a program on
the web server that can look at your request (what you searched for, or who
you are logged in as, or where you are requesting from, or any other
condition) and create an HTML page specifically for that request.
Web pages that come from .html files on the server are called static web
pages. Web pages that are created as they are requested are called dynamic
web pages.
Writing programs to create dynamic pages is server-side programming since
the programs run on the web server. The programming we have been doing
in JavaScript, where the programs run in the user’s web browser, is called
client-side programming.
We have only made static web pages in this course. That has given us a
good chance to explore the basic ideas of the web, and given us a place to
put JavaScript code to learn about (client-side) programming and do some
interaction with the user.
Creating dynamic web pages requires a few more things that we won’t be
doing in detail here.
First, the web server needs to be configured to actually run a program to
generate a response (instead of just finding a file on disk). This is often the
biggest barrier to exploring server-side programming: you need a web server
and need to set it up appropriately. This isn’t terribly
difficult or expensive, but it can be a challenge for beginners.
Second, you need to be able to write programs that generate the HTTP
response for the user.
This generally means creating HTML with your code. Exactly how that is done
depends on the page you need to create: it will probably involve reading
information from a database, or collecting information from some other
source.
6.3. Socket Programming
Data Communication and Computer Networks (ITec2102) CHAPTER SIX: CLIENT SERVER

COMPUTING 6.3. Socket Programming

Sockets allow communication between two different processes on the same


or different machines. To be more precise, it’s a way to talk to other
computers using standard Unix file descriptors. In Unix, every I/O action is
done by writing or reading a file descriptor. A file descriptor is just an integer
associated with an open file and it can be a network connection, a text file, a
terminal, or something else.

To a programmer, a socket looks and behaves much like a low-level file


descriptor. This is because commands such as read() and write() work with
sockets in the same way they do with files and pipes.
Sockets were first introduced in 2.1BSD and subsequently refined into their
current form with 4.2BSD. The sockets feature is now available with most
current UNIX system releases.

Where is Socket Used?

A Unix Socket is used in a client-server application framework. A server is a


process that performs some functions on request from a client. Most of the
application-level protocols like FTP, SMTP, and POP3 make use of sockets to
establish connection between client and server and then for exchanging
data.

Socket Types

There are four types of sockets available to the users. The first two are most
commonly used and the last two are rarely used.
Processes are presumed to communicate only between sockets of the same
type but there is no restriction that prevents communication between
sockets of different types.

 Stream Sockets – Delivery in a networked environment is guaranteed. If you send


through the stream socket three items “A, B, C”, they will arrive in the same order –
“A, B, C”. These sockets use TCP (Transmission Control Protocol) for data
transmission. If delivery is impossible, the sender receives an error indicator. Data
records do not have any boundaries.
 Datagram Sockets – Delivery in a networked environment is not guaranteed.
They’re connectionless because you don’t need to have an open connection as in
Stream Sockets- you build a packet with the destination information and send it out.
They use UDP (User Datagram Protocol).
 Raw Sockets – These provide users access to the underlying communication
protocols, which support socket abstractions. These sockets are normally datagram
oriented, though their exact characteristics are dependent on the interface provided
by the protocol. Raw sockets are not intended for the general user; they have been
provided mainly for those interested in developing new communication protocols, or
for gaining access to some of the more cryptic facilities of an existing protocol.
 Sequenced Packet Sockets – They are similar to a stream socket, with the
exception that record boundaries are preserved. This interface is provided only as a
part of the Network Systems (NS) socket abstraction, and is very important in most
serious NS applications. Sequenced-packet sockets allow the user to manipulate the
Sequence Packet Protocol (SPP) or Internet Datagram Protocol (IDP) headers on a
packet or a group of packets, either by writing a prototype header along with
whatever data is to be sent, or by specifying a default header to be used with all
outgoing data, and allows the user to receive the headers on incoming packets.

Socket programming is a way of connecting two nodes on a network to


communicate with each other. One socket (node) listens on a particular port
at an IP, while other socket reaches out to the other to form a connection.
Server forms the listener socket while client reaches out to the
server.
A socket is a communications connection point (endpoint) that you can name
and address in a network. Socket programming shows how to use socket
APIs to establish communication links between remote and local processes.
The processes that use a socket can reside on the same system or different
systems on different networks. Sockets are useful for both stand-alone and
network applications. Sockets allow you to exchange information between
processes on the same machine or across a network, distribute
work to the most efficient machine, and they easily allow access to
centralized data. Socket application program interfaces (APIs) are the
network standard for TCP/IP. A wide range of operating systems support
socket APIs. IBM® i sockets support multiple transport and networking
protocols. Socket system functions and the socket network functions are
threadsafe.
Programmers who use Integrated Language Environment® (ILE) C can refer
to this topic collection to develop socket applications. You can also code to
the sockets API from other ILE languages, such as RPG.

6.4. Server Sockets


Data Communication and Computer Networks (ITec2102) CHAPTER SIX: CLIENT SERVER

COMPUTING 6.4. Server Sockets

TCP server-socket programming is almost as simple as client socket


programming. A single class (ServerSocket) is used to create and manage
TCP client socket connections.
The ServerSocket binds to a port and waits for new TCP client connections.
When a new TCP client connection is received, an instance of the Socket
class is created by the ServerSocket instance and used to communicate with
the remote client. All of the same techniques described in the previous
section can be used with this newly created Socket instance.
The ServerSocket class provides several constructors and methods useful for
binding a TCP server socket to a local IP address and port. These
constructors are used to define the Ideal IP addresses, the local port, and the
connection backlog parameters to be used. The remaining methods are used
to receive new TCP connections, fine-tune various aspects of newly created
Socket instances, determine the binding state, and for closing of the socket.
Relatively few of the constructors and methods are needed to implement
basic TCP server-socket functionality (see Example 5.5). In this example, the
LineNumberReader class is used to read the TCP client request line-by-line. It
is important to note that this TCP server is single-threaded and will close or
exit upon receiving and sending one string.
Sockets are commonly used for client and server interaction. Typical system
configuration places the server on one machine, with the clients on other
machines. The clients connect to the server, exchange information, and then
disconnect.
A socket has a typical flow of events. In a connection-oriented client-to-
server model, the socket on the server process waits for requests from a
client. To do this, the server first establishes (binds) an address that clients
can use to find the server. When the address is established, the server waits
for clients to request a service. The client-to-server data exchange takes
place when a client connects to the server through a socket. The server
performs the client’s request and sends the reply back to the client.
The following figure shows the typical flow of events (and the sequence of
issued APIs) for a connection-oriented socket session. An explanation of each
event follows the figure.
This is a typical flow of events for a connection-oriented socket

1. The socket() API creates an endpoint for communications and returns a


socket descriptor that represents the endpoint.
2. When an application has a socket descriptor, it can bind a unique name to
the socket. Servers must bind a name to be accessible from the network.
3. The listen() API indicates a willingness to accept client connection
requests. When a listen() API is issued for a socket, that socket cannot
actively initiate connection requests. The listen() API is issued after a socket
is allocated with a socket() API and the bind() API binds a name to the socket.
A listen() API must be issued before an accept() API is issued.
4. The client application uses a connect() API on a stream socket to establish
a connection to the server.
5. The server application uses the accept() API to accept a client connection
request. The server must issue the bind() and listen() APIs successfully
before it can issue an accept() API.

6. When a connection is established between stream sockets (between client


and server), you can use any of the socket API data transfer APIs. Clients and
servers have many data transfer APIs from which to choose, such as send(),
recv(), read(), write(), and others.
7. When a server or client wants to stop operations, it issues a close() API to
release any system resources acquired by the socket.

Multithreading Concepts

Multithreading is the ability of a program or an operating system process to


manage its use by more than one user at a time and to even manage
multiple requests by the same user without having to have multiple copies of
the programming running in the computer. Each user request for a program
or system service (and here a user can also be another program) is kept
track of as a thread with a separate identity. As programs work on behalf of
the initial request for that thread and are interrupted by other requests, the
status of work on behalf of that thread is kept track of until the work is
completed.

Multithreading is a CPU (central processing unit) feature that allows two or


more instruction threads to execute independently while sharing the same
process resources. A thread is a selfcontained sequence of instructions that
can execute in parallel with other threads that are part of the same root
process.

Multithreading allows multiple concurrent tasks can be performed within a


single process. When data scientists are training machine learning
algorithms, a multithreaded approach to programming can improve speed
when compared to traditional parallel multiprocessing programs.

Even though it’s faster for an operating system (OS) to switch between
threads for an active CPU task than it is to switch between different
processes, multithreading requires careful programming in order to avoid
conflicts caused by race conditions and deadlocks.
To prevent race conditions and deadlocks, programmers use locks that
prevent multiple threads from modifying the value of the same variable at
the same time.
In programming, a thread maintains a list of information relevant to its
execution, including the priority schedule, exception handlers, a set of CPU
registers, and stack state in the address space of its hosting process.
Threading can be useful in a single-processor system because it allows the
primary execution thread to be responsive to user input while supporting
threads execute longrunning tasks in the background that do not require
user intervention.

When thinking about how multithreading is done, it’s important to separate


the two concepts of parallel and concurrent processing.
Parallel multiprocessing means the system is actually handling more than
one thread at a given time. Concurrent processing means that only one
thread will be handled at a time, but the system will create efficiencies by
moving quickly between two or more threads.
Another important thing to note is that for practical purposes, computer
systems set up for human users can have parallel or concurrent systems,
with the same end result – the process looks parallel to the user because the
computer is working so quickly in terms of microseconds.
The evolution of multicore systems means that there is more parallelism,
which alleviates the need for efficient concurrent processing. The
development of faster and more powerful microchips and processors on this
end of the expansion of Moore’s law is important to this type of hardware
design and engineering in general.

In addition, much of the parallel or concurrent processing is made available


according to the vagaries of the operating system. So in effect, to the human
user, either parallel or concurrent process, or processes that are mixed, are
all experienced as parallelism in real-time.

Types of Multithreading

Different types of multithreading apply to various versions of operating


systems and related controls that have evolved in computing: for example,
in pre-emptive multithreading, the context switch is controlled by the
operating system. Then there’s cooperative multithreading, in which context
switching is controlled by the thread. This could lead to problems, such as
deadlocks if a thread is blocked waiting for a resource to become free.
Many other types of models for multithreading also apply, for example,
coarse-grained, interleaved and simultaneous multithreading models will
determine how the threads are coordinated and processed. Other options for
multithreading include many to many, many to one and one to one models.
Some models will use concepts like equal time slices to try to portion out
execution among threads. The type of multithreading depends on the system
itself, its philosophy and its build, and how the engineers planned
multithreading functionality within it.
In the active/passive system model, one thread remains responsive to a
user, and another thread works on longer-term tasks in the background. This
model is useful for promoting a system that looks parallel from a user
viewpoint, which brings us to a major point in evaluating processes like micro
threading from both ends: from the perspective of the engineer, and the
perspective of the end-user.

Previous T

You might also like