1. •Protocol,
•Sockets,
•Knowing IP Address,
•URL,
•Reading the Source Code of a Web Page,
•Downloading a Web Page from Internet,
•Downloading an Image from Internet,
•A TCP/IP Server,
•A TCP/IP Client,
•A UDP Server, A UDP Client,
•File Server,
•File Client,
•Two-Way Communication between Server and Client,
•Sending a Simple Mail,
2. Interconnection of computer is called a
network.
A simple network can be formed by
connecting two computers using a cable.
So network can have two computers or
two thousand computers.
For ex. Internet
Advantage of network is sharing the
resources.
For ex. Bank customer
3. A Computer networking model where one
or more powerful computers (servers)
provide the different computer network
services and all other user'of
computer network (clients) access those
services to perform user's tasks is known
as client/server computer networking
model.
4. In such networks, there exists a central
controller called server.
A server is a specialized computer that controls
the network resources and provides services to
other computers in the network.
All other computers in the network are called
clients.
A client computer receives the requested
services from a server.
A server performs all the major operations like
security and network management.
All the clients communicate with each other via
centralized server
5.
6. pros of Client Server Networks
• Centralized back up is possible.
• Use of dedicated server improves the performance
of whole system.
cons of Client Server Networks
• It requires specialized servers with large memory
and secondary storage. This leads to increase in the
cost.
• The cost of network operating system that manages
the various clients is also high.
• It requires dedicated network administrator.
7. Hardware: includes computers, cables,
modems, routers, hubs, etc.
Software: Includes programs to
communicate b/w servers and clients.
Protocol: Represents a way to establish
connection and helps in sending and
receiving data in a standard format.
8. A protocol represents a set of rules to be followed by
every computer on the network.
Protocol is useful to physically move data from one
place to another place on a network.
While sending data or receiving data, the computer
wants to send a file on a network, it is not possible to
send the entire file in a single step.
The file should be broken into small pieces and then
only they can be sent to other computer.
Two types protocol which other protocols are
developed.
• TCP/IP Protocol
• UDP
9. TCP (Transmission Control Protocol) /IP
(internet protocol) is the standard protocol
model used on any network, including
internet.
TCP/IP model has five layers.
• Application layer
• TCP
• IP
• Data Link Layer
• Physical Layer
10. UDP is another protocol that transfer data in a
connection less and unreliable manner.
It will not check how many bits are sent or how many
bits are actually received at the other side.
During transmission of data, there may be loss of
some bits.
Also, the data sent may not be received in the same
order.
So, UDP is not used to send text.
UDP is used to send images, audio files, and
video files.
Even if some bits are lost, still the image or audio file
can be composed with a slight variation that will not
disturb the original image or audio.
11. Establish a connecting point b/w a server and a client
so the communication done through that point called
socket.
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.
They are the real backbones behind web browsing. In
simpler terms there is a server and a client.
Every new service on the net should be assigned a
new port number.
12. Each socket given an identification
number, which is called port number.
Port number takes 2 bytes and can be
from 0 to 65,535.
13. Port Number Application or service
13 Date and time services
21 FTP which transfer files
23 telnet, which provides remote login
25 SMTP, which delivers mails
67 BOOTP, which provides configuration at boot time
80 HTTP, which transfer web pages
109 POP2, which is a mailing service
110 POP3, which is a mailing service
119 NNTP, which is for transferring news articles
443 HTTPS, which transfer web pages securely
14. To create a socket, you must use
the socket.socket() function available in socket module,
which has the general syntax −
• s = socket.socket (socket_family, socket_type, protocol=0)
Here, first argument ‘socket family’ indicates which
version of the ip address should be used, whether IP
address version 4 or version 6.
This argument can take either of the following two values:
• socket.AF_INET #IPV4 – this is default
• socket.AF_INET6 #IPV6
The second argument is ‘type’ which represents the type
of the protocol to be used, whether TCP/IP or UDP.
Following two values:
• socket.SOCK_STREAM #for TCP –this is default
• socket.SOCK_DGRAM #for UDP
15. To know the IP address of a website on
internet, we can use gethostbyname()
function available in socket module.
This function takes the website name and
returns its ip address.
• Addr=socket.gethostbyname(‘www.google.co.in’)
If there is no such website on internet, then it
return ‘gaierror’ (Get Address Information Error)
16. URL (Uniform resource locator) represents
the address that is specified to access some
information or resource on internet. For ex.
http://www.google.com:80/index.html
• The protocol to use http://
• The server name or ip address of the server
(www.google.com)
• 3rd part port number, which is optional (:80)
• Last part is the file that is referred.
17. When url is given we can parse the url and
find out all the parts of the url with the help
of urlparse() function of urllib.parse module
in python.
It returns a tuple containing the parts of the
url.
Tpl= urllib.aprse.urlparse(‘urlstring’)
Following attributes are used to retrieve
the individual parts of the url.
18. Scheme: this gives the protocol name
used in the url
Netloc: gives the website name on the net
with port number if present.
Path: gives the path of the web page.
Port: gives the port number
19. A server is a program that provides services
to other computers on the network or internet.
Similarly a client is a program that receives
services from the server.
When a server wants to communicate with a
client, there is a need of a socket.
A socket is a point of connection b/w the
server and client.
20. 1. Create a TCP/IP socket at server side using
socket() function.
2. Bind the socket with host name and port
number using bind((host,port)) method.
3. Specify maximum number of connection
using listen(1) method.
4. Server should wait till a client accepts
connection.
C, addr= s.accept() # c is a connection obj, addr
adddress of client
21. 5. send(b”msgstring”) method to send
message to client. Message should be sent in
the form of byte streams.
6. Convert message in binary format use
string.encode() method.
7. Close the connection using close() method.
22. A client is a program that receives the data
or services from the server.
Steps for client program
1. Create socket obj using socket() function.
2. Use connect((host,port)) method to connect
the socket.
3. Receive msg from the server use
recv(1024) method. Here, 1024 is buffer
size that is bytes received from the server.
4. Disconnect the client using close() method.
23. If we want to create a server that uses UDP
protocol to send messages. We have to
specify socket.SOCK_DGRAM in socket obj.
Using sendto() function the server can send
data to client, but UDP is a connection-less
protocol, server does not know where the
data shoud be sent, so we specify the client
address in sendto() method.
• S.sendto(“msg string”,(host,port))
24. 1. At the client side socket should be
created using socket function.
2. Socket should be bind using
bind((host,port)) method.
3. The client can receive messages with the
help of recvfrom(1024) method.
4. Receive all messages using while loop.
5. And settimeout(5) method so client will
automatically disconnect after that time
elapses.