Copyright © 2017, edureka and/or its affiliates. All rights reserved.
• What are sockets?
• How to achieve Socket Programming in Python?
• Servers and Clients
• Client-Server Communication
• Transferring Python Objects
www.edureka.co/python
www.edureka.co/python
• Sockets are interior endpoints built for sending
and receiving data
• A single network will have two sockets
• Sockets are a combination of an IP address and a
Port
www.edureka.co/python
Protocol Port Number Python Library Function
HTTP 80 httplib, urllib,xmlrpclib Web pages
FTP 20 ftplib, urllib File transfers
NNTP 119 nntplib Unsent news
SMTP 25 smtplib Sending email
Telnet 23 telnetlib Command lines
POP3 110 poplib Fetching email
Gopher 70 gopherlib Document transfer
Common port numbers and the related protocols
Common Port Numbers
www.edureka.co/python
www.edureka.co/python
• Import the socket module or framework
• This module consists of built-in methods that are
required for creating sockets and help them associate
with each other
www.edureka.co/python
Methods Description
socket.socket()
Used to create sockets (required on both server as well as
client ends to create sockets)
socket.accept()
Used to accept a connection. It returns a pair of values (conn,
address)
socket.bind() Used to bind to the address that is specified as a parameter
socket.close() Used to bind to the address that is specified as a parameter
socket.connect() Used to mark the socket as closed
socket.listen()
Used to connect to a remote address specified as the
parameter
Important methods of the socket module
www.edureka.co/python
www.edureka.co/python
www.edureka.co/python
• Either a program, a computer, or a device
• Devoted to managing network resources
• Can be on the same device or computer or local or even
remote
Server
Client
• Computer or software that receives information or services
• Clients requests for services from servers
• The best example is a web browser
www.edureka.co/python
www.edureka.co/python
www.edureka.co/python
• Socket Programming in Python also
allows you to transfer Python objects
such as sets, tuples, dictionaries, etc.
• To achieve this, you need to import
the pickle module.
www.edureka.co/python
Copyright © 2019, edureka and/or its affiliates. All rights reserved.
www.edureka.co/python

What is Socket Programming in Python | Edureka

  • 1.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved.
  • 2.
    • What aresockets? • How to achieve Socket Programming in Python? • Servers and Clients • Client-Server Communication • Transferring Python Objects www.edureka.co/python
  • 3.
  • 4.
    • Sockets areinterior endpoints built for sending and receiving data • A single network will have two sockets • Sockets are a combination of an IP address and a Port www.edureka.co/python
  • 5.
    Protocol Port NumberPython Library Function HTTP 80 httplib, urllib,xmlrpclib Web pages FTP 20 ftplib, urllib File transfers NNTP 119 nntplib Unsent news SMTP 25 smtplib Sending email Telnet 23 telnetlib Command lines POP3 110 poplib Fetching email Gopher 70 gopherlib Document transfer Common port numbers and the related protocols Common Port Numbers www.edureka.co/python
  • 6.
  • 7.
    • Import thesocket module or framework • This module consists of built-in methods that are required for creating sockets and help them associate with each other www.edureka.co/python
  • 8.
    Methods Description socket.socket() Used tocreate sockets (required on both server as well as client ends to create sockets) socket.accept() Used to accept a connection. It returns a pair of values (conn, address) socket.bind() Used to bind to the address that is specified as a parameter socket.close() Used to bind to the address that is specified as a parameter socket.connect() Used to mark the socket as closed socket.listen() Used to connect to a remote address specified as the parameter Important methods of the socket module www.edureka.co/python
  • 9.
  • 10.
    www.edureka.co/python • Either aprogram, a computer, or a device • Devoted to managing network resources • Can be on the same device or computer or local or even remote Server Client • Computer or software that receives information or services • Clients requests for services from servers • The best example is a web browser www.edureka.co/python
  • 11.
  • 12.
  • 13.
    • Socket Programmingin Python also allows you to transfer Python objects such as sets, tuples, dictionaries, etc. • To achieve this, you need to import the pickle module. www.edureka.co/python
  • 14.
    Copyright © 2019,edureka and/or its affiliates. All rights reserved.
  • 15.