[go: up one dir, main page]

0% found this document useful (0 votes)
39 views6 pages

Network ch6

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

Network ch6

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

Chapter 6: Client-server computing

Topics:
6.1. Web technologies:
6.1.1. Server-side programs
6.1.2. Socket programs
6.1.3. Server and Client sockets
6.1.4. Multithreading concepts

6.1. Web technologies


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: 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.

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.
6.1.1. Server-side programs
For different sites, 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.

Creating dynamic web pages requires a few more things that we won’t be doing in detail here.

1. The web server needs to be configured to actually run a program to generate a response (instead of
just finding a file on disk).
2. 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.1.2. 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.

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

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.

1. 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.
2. 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).
3. 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.
4. 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

6.1.3. Server and Client 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.

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.

Figure 1: Client Server Communication


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.

6.1.4. 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 self-contained 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.

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.

The evolution of multicore systems means that there is more parallelism, which alleviates the need for
efficient concurrent processing.

Types of Multithreading

Different types of multithreading apply to various versions of operating systems and related controls that
have evolved in computing:

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.

The type of multithreading depends on the system itself, its philosophy and its build, and how the
engineers planned multithreading functionality within it.

Review Questions:

1. Discuss on web technologies?


2. What is server computer means?
3. How client and server communicate each other?
4. What is socket programming?
5. Discus on socket server concepts?
6. What is Multithreading means?

You might also like