SlideShare a Scribd company logo
•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,
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
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.
 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
Networking in python by Rj
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.
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.
 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
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
 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.
 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.
Each socket given an identification
number, which is called port number.
Port number takes 2 bytes and can be
from 0 to 65,535.
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
 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
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)
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.
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.
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
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.
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
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.
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.
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))
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.
File Server & File Client
Two way communication b/w
server and client
Sending a simple Email

More Related Content

PDF
Network programming Using Python
PDF
Python network programming
PPTX
Advanced Python : Decorators
PPS
Wrapper class
PPT
Python GUI Programming
PPTX
Constructor in java
PPSX
Data Types & Variables in JAVA
Network programming Using Python
Python network programming
Advanced Python : Decorators
Wrapper class
Python GUI Programming
Constructor in java
Data Types & Variables in JAVA

What's hot (20)

PPTX
PPTX
Functions in C
PDF
Strings in java
PPTX
Android activity lifecycle
PDF
Java Thread Synchronization
PPT
1.python interpreter and interactive mode
PPTX
Thread priority in java
PDF
OOP Assignment 03.pdf
PPT
List in java
PPTX
I/O Streams
PPT
JAVA OOP
PPTX
PPTX
Python: Polymorphism
PDF
Java I/o streams
PDF
JavaScript - Chapter 12 - Document Object Model
PPTX
Java swing
PPT
Thread model in java
PDF
Java threads
PPTX
Constructor in java
Functions in C
Strings in java
Android activity lifecycle
Java Thread Synchronization
1.python interpreter and interactive mode
Thread priority in java
OOP Assignment 03.pdf
List in java
I/O Streams
JAVA OOP
Python: Polymorphism
Java I/o streams
JavaScript - Chapter 12 - Document Object Model
Java swing
Thread model in java
Java threads
Constructor in java
Ad

Similar to Networking in python by Rj (20)

PPTX
Networking in Java
PDF
Socket programming assignment
PPTX
PYTHON -Chapter 5 NETWORK - MAULIK BORSANIYA
PPTX
Network Programming-Python-13-8-2023.pptx
PPT
chapter-4-networking hjgjjgj did hfhhfhj
DOCX
Final networks lab manual
PDF
introduction to computer network lecture one
PPTX
Network programming using python
PPTX
IT-NET GROUP 3 REPORT.pptx
PDF
Socket programming using java
PPTX
INTERNET PROGRAMMING unit1 web essential
PDF
NETWORKING DEVICES AND CABLING NOTES FOR FIRST DEGREE STUDENTS
PPTX
Basics of Socket Programming using python
PPT
07 - TCP_IP and the DoD Model.ppt
PPTX
Ch4 Protocols.pptx
PPTX
Ch4 Protocols.pptx
PDF
Networking Basics1ofjavaprogramming.pptx.pdf
PPTX
Chuong5_Networking_updated.Networking_updatedpptx
PPT
INTRODUCTION TO INTERNET PROTOCOL BY SAIKIRAN PANJALA
Networking in Java
Socket programming assignment
PYTHON -Chapter 5 NETWORK - MAULIK BORSANIYA
Network Programming-Python-13-8-2023.pptx
chapter-4-networking hjgjjgj did hfhhfhj
Final networks lab manual
introduction to computer network lecture one
Network programming using python
IT-NET GROUP 3 REPORT.pptx
Socket programming using java
INTERNET PROGRAMMING unit1 web essential
NETWORKING DEVICES AND CABLING NOTES FOR FIRST DEGREE STUDENTS
Basics of Socket Programming using python
07 - TCP_IP and the DoD Model.ppt
Ch4 Protocols.pptx
Ch4 Protocols.pptx
Networking Basics1ofjavaprogramming.pptx.pdf
Chuong5_Networking_updated.Networking_updatedpptx
INTRODUCTION TO INTERNET PROTOCOL BY SAIKIRAN PANJALA
Ad

More from Shree M.L.Kakadiya MCA mahila college, Amreli (20)

Recently uploaded (20)

PDF
Modernizing your data center with Dell and AMD
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPT
Teaching material agriculture food technology
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
cuic standard and advanced reporting.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Encapsulation theory and applications.pdf
PPTX
A Presentation on Artificial Intelligence
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Approach and Philosophy of On baking technology
Modernizing your data center with Dell and AMD
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Teaching material agriculture food technology
NewMind AI Weekly Chronicles - August'25 Week I
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Dropbox Q2 2025 Financial Results & Investor Presentation
20250228 LYD VKU AI Blended-Learning.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
Spectral efficient network and resource selection model in 5G networks
cuic standard and advanced reporting.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Encapsulation theory and applications.pdf
A Presentation on Artificial Intelligence
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
MYSQL Presentation for SQL database connectivity
Advanced methodologies resolving dimensionality complications for autism neur...
NewMind AI Monthly Chronicles - July 2025
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Approach and Philosophy of On baking technology

Networking in python by Rj

  • 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
  • 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.
  • 25. File Server & File Client
  • 26. Two way communication b/w server and client