SlideShare uma empresa Scribd logo
1 de 27
•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
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

Mais conteúdo relacionado

Mais procurados

Advanced Python Tutorial | Learn Advanced Python Concepts | Python Programmin...
Advanced Python Tutorial | Learn Advanced Python Concepts | Python Programmin...Advanced Python Tutorial | Learn Advanced Python Concepts | Python Programmin...
Advanced Python Tutorial | Learn Advanced Python Concepts | Python Programmin...Edureka!
 
Python-02| Input, Output & Import
Python-02| Input, Output & ImportPython-02| Input, Output & Import
Python-02| Input, Output & ImportMohd Sajjad
 
Socket programming
Socket programmingSocket programming
Socket programmingNemiRathore
 
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...Edureka!
 
Java Course 8: I/O, Files and Streams
Java Course 8: I/O, Files and StreamsJava Course 8: I/O, Files and Streams
Java Course 8: I/O, Files and StreamsAnton Keks
 
Python - gui programming (tkinter)
Python - gui programming (tkinter)Python - gui programming (tkinter)
Python - gui programming (tkinter)Learnbay Datascience
 
Introduction to Game programming with PyGame Part 1
Introduction to Game programming with PyGame Part 1Introduction to Game programming with PyGame Part 1
Introduction to Game programming with PyGame Part 1Abhishek Mishra
 
Python Advanced – Building on the foundation
Python Advanced – Building on the foundationPython Advanced – Building on the foundation
Python Advanced – Building on the foundationKevlin Henney
 
Functions and modules in python
Functions and modules in pythonFunctions and modules in python
Functions and modules in pythonKarin Lagesen
 
What is Multithreading In Python | Python Multithreading Tutorial | Edureka
What is Multithreading In Python | Python Multithreading Tutorial | EdurekaWhat is Multithreading In Python | Python Multithreading Tutorial | Edureka
What is Multithreading In Python | Python Multithreading Tutorial | EdurekaEdureka!
 
Django Introduction & Tutorial
Django Introduction & TutorialDjango Introduction & Tutorial
Django Introduction & Tutorial之宇 趙
 
Java Socket Programming
Java Socket ProgrammingJava Socket Programming
Java Socket ProgrammingVipin Yadav
 
Introduction to-python
Introduction to-pythonIntroduction to-python
Introduction to-pythonAakashdata
 
PYTHON - TKINTER - GUI - PART 1.ppt
PYTHON - TKINTER - GUI - PART 1.pptPYTHON - TKINTER - GUI - PART 1.ppt
PYTHON - TKINTER - GUI - PART 1.pptPriyaSoundararajan1
 

Mais procurados (20)

Advanced Python Tutorial | Learn Advanced Python Concepts | Python Programmin...
Advanced Python Tutorial | Learn Advanced Python Concepts | Python Programmin...Advanced Python Tutorial | Learn Advanced Python Concepts | Python Programmin...
Advanced Python Tutorial | Learn Advanced Python Concepts | Python Programmin...
 
Python-02| Input, Output & Import
Python-02| Input, Output & ImportPython-02| Input, Output & Import
Python-02| Input, Output & Import
 
Socket programming
Socket programmingSocket programming
Socket programming
 
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
 
Java Course 8: I/O, Files and Streams
Java Course 8: I/O, Files and StreamsJava Course 8: I/O, Files and Streams
Java Course 8: I/O, Files and Streams
 
Python - gui programming (tkinter)
Python - gui programming (tkinter)Python - gui programming (tkinter)
Python - gui programming (tkinter)
 
Introduction to Game programming with PyGame Part 1
Introduction to Game programming with PyGame Part 1Introduction to Game programming with PyGame Part 1
Introduction to Game programming with PyGame Part 1
 
Python Advanced – Building on the foundation
Python Advanced – Building on the foundationPython Advanced – Building on the foundation
Python Advanced – Building on the foundation
 
Python basics
Python basicsPython basics
Python basics
 
Python cgi programming
Python cgi programmingPython cgi programming
Python cgi programming
 
Socket Programming
Socket ProgrammingSocket Programming
Socket Programming
 
Functions and modules in python
Functions and modules in pythonFunctions and modules in python
Functions and modules in python
 
Files in php
Files in phpFiles in php
Files in php
 
What is Multithreading In Python | Python Multithreading Tutorial | Edureka
What is Multithreading In Python | Python Multithreading Tutorial | EdurekaWhat is Multithreading In Python | Python Multithreading Tutorial | Edureka
What is Multithreading In Python | Python Multithreading Tutorial | Edureka
 
Exception handling in python
Exception handling in pythonException handling in python
Exception handling in python
 
Django Introduction & Tutorial
Django Introduction & TutorialDjango Introduction & Tutorial
Django Introduction & Tutorial
 
Java Socket Programming
Java Socket ProgrammingJava Socket Programming
Java Socket Programming
 
VB net lab.pdf
VB net lab.pdfVB net lab.pdf
VB net lab.pdf
 
Introduction to-python
Introduction to-pythonIntroduction to-python
Introduction to-python
 
PYTHON - TKINTER - GUI - PART 1.ppt
PYTHON - TKINTER - GUI - PART 1.pptPYTHON - TKINTER - GUI - PART 1.ppt
PYTHON - TKINTER - GUI - PART 1.ppt
 

Semelhante a Networking in python by Rj

PYTHON -Chapter 5 NETWORK - MAULIK BORSANIYA
PYTHON -Chapter 5 NETWORK - MAULIK BORSANIYAPYTHON -Chapter 5 NETWORK - MAULIK BORSANIYA
PYTHON -Chapter 5 NETWORK - MAULIK BORSANIYAMaulik Borsaniya
 
Byte Ordering - Unit 2.pptx
Byte Ordering - Unit 2.pptxByte Ordering - Unit 2.pptx
Byte Ordering - Unit 2.pptxRockyBhai46825
 
Socket Programming
Socket ProgrammingSocket Programming
Socket ProgrammingCEC Landran
 
Final networks lab manual
Final networks lab manualFinal networks lab manual
Final networks lab manualJaya Prasanna
 
Networking.pptx
Networking.pptxNetworking.pptx
Networking.pptxEsubesisay
 
Application Layer and Socket Programming
Application Layer and Socket ProgrammingApplication Layer and Socket Programming
Application Layer and Socket Programmingelliando dias
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in JavaTushar B Kute
 
presentation on TCP/IP protocols data comunications
presentation on TCP/IP protocols data comunicationspresentation on TCP/IP protocols data comunications
presentation on TCP/IP protocols data comunicationsAnyapuPranav
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in JavaTushar B Kute
 
Network Programming-Python-13-8-2023.pptx
Network Programming-Python-13-8-2023.pptxNetwork Programming-Python-13-8-2023.pptx
Network Programming-Python-13-8-2023.pptxssuser23035c
 
Mail Server Project Report
Mail Server Project ReportMail Server Project Report
Mail Server Project ReportKavita Sharma
 
Network Programming in Java
Network Programming in JavaNetwork Programming in Java
Network Programming in JavaTushar B Kute
 

Semelhante a Networking in python by Rj (20)

Md13 networking
Md13 networkingMd13 networking
Md13 networking
 
PYTHON -Chapter 5 NETWORK - MAULIK BORSANIYA
PYTHON -Chapter 5 NETWORK - MAULIK BORSANIYAPYTHON -Chapter 5 NETWORK - MAULIK BORSANIYA
PYTHON -Chapter 5 NETWORK - MAULIK BORSANIYA
 
Byte Ordering - Unit 2.pptx
Byte Ordering - Unit 2.pptxByte Ordering - Unit 2.pptx
Byte Ordering - Unit 2.pptx
 
Socket Programming
Socket ProgrammingSocket Programming
Socket Programming
 
Lecture set 7
Lecture set 7Lecture set 7
Lecture set 7
 
Final networks lab manual
Final networks lab manualFinal networks lab manual
Final networks lab manual
 
Intake 38 11
Intake 38 11Intake 38 11
Intake 38 11
 
Networking.pptx
Networking.pptxNetworking.pptx
Networking.pptx
 
Application Layer and Socket Programming
Application Layer and Socket ProgrammingApplication Layer and Socket Programming
Application Layer and Socket Programming
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
 
Unit 8 Java
Unit 8 JavaUnit 8 Java
Unit 8 Java
 
presentation on TCP/IP protocols data comunications
presentation on TCP/IP protocols data comunicationspresentation on TCP/IP protocols data comunications
presentation on TCP/IP protocols data comunications
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
 
28 networking
28  networking28  networking
28 networking
 
Network Programming-Python-13-8-2023.pptx
Network Programming-Python-13-8-2023.pptxNetwork Programming-Python-13-8-2023.pptx
Network Programming-Python-13-8-2023.pptx
 
Mail Server Project Report
Mail Server Project ReportMail Server Project Report
Mail Server Project Report
 
Networking in Java
Networking in JavaNetworking in Java
Networking in Java
 
Network Programming in Java
Network Programming in JavaNetwork Programming in Java
Network Programming in Java
 
NP-lab-manual (1).pdf
NP-lab-manual (1).pdfNP-lab-manual (1).pdf
NP-lab-manual (1).pdf
 
NP-lab-manual.pdf
NP-lab-manual.pdfNP-lab-manual.pdf
NP-lab-manual.pdf
 

Mais de Shree M.L.Kakadiya MCA mahila college, Amreli

Mais de Shree M.L.Kakadiya MCA mahila college, Amreli (20)

Machine Learning by Rj
Machine Learning by RjMachine Learning by Rj
Machine Learning by Rj
 
Listeners and filters in servlet
Listeners and filters in servletListeners and filters in servlet
Listeners and filters in servlet
 
Servlet unit 2
Servlet unit 2 Servlet unit 2
Servlet unit 2
 
Servlet by Rj
Servlet by RjServlet by Rj
Servlet by Rj
 
Research paper on python by Rj
Research paper on python by RjResearch paper on python by Rj
Research paper on python by Rj
 
Jsp in Servlet by Rj
Jsp in Servlet by RjJsp in Servlet by Rj
Jsp in Servlet by Rj
 
Motion capture by Rj
Motion capture by RjMotion capture by Rj
Motion capture by Rj
 
Research paper on big data and hadoop
Research paper on big data and hadoopResearch paper on big data and hadoop
Research paper on big data and hadoop
 
Text processing by Rj
Text processing by RjText processing by Rj
Text processing by Rj
 
Python and data analytics
Python and data analyticsPython and data analytics
Python and data analytics
 
Multithreading by rj
Multithreading by rjMultithreading by rj
Multithreading by rj
 
Django by rj
Django by rjDjango by rj
Django by rj
 
Database programming
Database programmingDatabase programming
Database programming
 
CGI by rj
CGI by rjCGI by rj
CGI by rj
 
Adv. python regular expression by Rj
Adv. python regular expression by RjAdv. python regular expression by Rj
Adv. python regular expression by Rj
 
Seminar on Project Management by Rj
Seminar on Project Management by RjSeminar on Project Management by Rj
Seminar on Project Management by Rj
 
Spring by rj
Spring by rjSpring by rj
Spring by rj
 
Python by Rj
Python by RjPython by Rj
Python by Rj
 
Leadership & Motivation
Leadership & MotivationLeadership & Motivation
Leadership & Motivation
 
Event handling
Event handlingEvent handling
Event handling
 

Último

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Último (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

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