SlideShare a Scribd company logo
1 of 14
What is a socket ?
It is an interface between
application layer and transport
layer within a host.



     CNP Seminar by Jithin P      2
Application Layer




                               Transport Layer
   Socket


     CNP Seminar by Jithin P                     3
Why socket ?
Kannadasan                             Yamuna
For Identification

                                   ?



         CNP Seminar by Jithin P                4
Why socket ?
Hostel Name + Room No
                                    IP address + Port number


                  Socket



          CNP Seminar by Jithin P                          5
listen()                      accept()



    CNP Seminar by Jithin P              6
listen()
 Called only by TCP server
 Performs two actions
         Convert the socket in to passive socket
         Specify the maximum number of connections the kernel
          should queue




                 CNP Seminar by Jithin P                         8
 For a listening socket the kernel maintains two queues
    An incomplete connection queue
         Waiting for 3-way handshake
   A complete connection queue
        Completed 3-way handshake




                 CNP Seminar by Jithin P                   9
3-way handshaking
              client                          server

  Connect called                                 Create entry on
                                                 incomplete queue


Connect returns

                                                 Entry moved from
                                                 incomplete queue to
                                                 complete queue




                    CNP Seminar by Jithin P                            10
int listen(int sockfd, int backlog)




         CNP Seminar by Jithin P      11
Questions ?
 What is the default size of backlog ?
 Which queue is longest one (complete/incomplete) ?
 What will happen when queue is full ?




              CNP Seminar by Jithin P                  12
accept()

                          Completed
                          connection queue




                           Incomplete
                            connection queue



    Arriving
    SYN

CNP Seminar by Jithin P                        13
accept()

int accept(int sockfd, socket addr, socket addrlen)

 If success return a brand new descriptor
 ie descriptor of connected socket.




             CNP Seminar by Jithin P                  14
References
 Unix Network Programming
       W.Richard Stevens
 Computer Networking a top down approach
       James F Kurose
 Wikipedia
 pubs.opengroup.org




                 CNP Seminar by Jithin P    15
Questions




CNP Seminar by Jithin P   16

More Related Content

What's hot (6)

From zero to gremlin hero - Part I
From zero to gremlin hero - Part IFrom zero to gremlin hero - Part I
From zero to gremlin hero - Part I
 
Welcome to International Journal of Engineering Research and Development (IJERD)
Welcome to International Journal of Engineering Research and Development (IJERD)Welcome to International Journal of Engineering Research and Development (IJERD)
Welcome to International Journal of Engineering Research and Development (IJERD)
 
Ch04
Ch04Ch04
Ch04
 
Syntax-based Simultaneous Translation through Prediction of Unseen Syntactic ...
Syntax-based Simultaneous Translation through Prediction of Unseen Syntactic ...Syntax-based Simultaneous Translation through Prediction of Unseen Syntactic ...
Syntax-based Simultaneous Translation through Prediction of Unseen Syntactic ...
 
Introduction To Video Compression
Introduction To Video CompressionIntroduction To Video Compression
Introduction To Video Compression
 
I phone 10
I phone 10I phone 10
I phone 10
 

Viewers also liked (6)

Domain name system
Domain name systemDomain name system
Domain name system
 
Presentation on Domain Name System
Presentation on Domain Name SystemPresentation on Domain Name System
Presentation on Domain Name System
 
Internet and World Wide Web
Internet and World Wide WebInternet and World Wide Web
Internet and World Wide Web
 
Chapter 26
Chapter 26Chapter 26
Chapter 26
 
world wide web
world wide webworld wide web
world wide web
 
Dns ppt
Dns pptDns ppt
Dns ppt
 

More from Jithin Parakka (9)

Towards cashless economy
Towards cashless economyTowards cashless economy
Towards cashless economy
 
Configuring D-link DSL-2730U Wireless N ADSL2+Router to connect BSNL broaddband
Configuring D-link DSL-2730U Wireless N ADSL2+Router to connect BSNL broaddbandConfiguring D-link DSL-2730U Wireless N ADSL2+Router to connect BSNL broaddband
Configuring D-link DSL-2730U Wireless N ADSL2+Router to connect BSNL broaddband
 
Cloud Computing Tools
Cloud Computing ToolsCloud Computing Tools
Cloud Computing Tools
 
Introduction to cloud computing
Introduction to cloud computingIntroduction to cloud computing
Introduction to cloud computing
 
Captcha
CaptchaCaptcha
Captcha
 
Semantic web tools
Semantic web toolsSemantic web tools
Semantic web tools
 
Market oriented Cloud Computing
Market oriented Cloud ComputingMarket oriented Cloud Computing
Market oriented Cloud Computing
 
Ubnutu Enterprise Cloud (EUC)
Ubnutu Enterprise Cloud (EUC)Ubnutu Enterprise Cloud (EUC)
Ubnutu Enterprise Cloud (EUC)
 
self healing optical access network
self healing optical access networkself healing optical access network
self healing optical access network
 

Recently uploaded

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 

Listen and accept function

  • 1. What is a socket ? It is an interface between application layer and transport layer within a host. CNP Seminar by Jithin P 2
  • 2. Application Layer Transport Layer Socket CNP Seminar by Jithin P 3
  • 3. Why socket ? Kannadasan Yamuna For Identification ? CNP Seminar by Jithin P 4
  • 4. Why socket ? Hostel Name + Room No IP address + Port number Socket CNP Seminar by Jithin P 5
  • 5. listen() accept() CNP Seminar by Jithin P 6
  • 6. listen()  Called only by TCP server  Performs two actions  Convert the socket in to passive socket  Specify the maximum number of connections the kernel should queue CNP Seminar by Jithin P 8
  • 7.  For a listening socket the kernel maintains two queues  An incomplete connection queue  Waiting for 3-way handshake  A complete connection queue  Completed 3-way handshake CNP Seminar by Jithin P 9
  • 8. 3-way handshaking client server Connect called Create entry on incomplete queue Connect returns Entry moved from incomplete queue to complete queue CNP Seminar by Jithin P 10
  • 9. int listen(int sockfd, int backlog) CNP Seminar by Jithin P 11
  • 10. Questions ?  What is the default size of backlog ?  Which queue is longest one (complete/incomplete) ?  What will happen when queue is full ? CNP Seminar by Jithin P 12
  • 11. accept() Completed connection queue Incomplete connection queue Arriving SYN CNP Seminar by Jithin P 13
  • 12. accept() int accept(int sockfd, socket addr, socket addrlen)  If success return a brand new descriptor  ie descriptor of connected socket. CNP Seminar by Jithin P 14
  • 13. References  Unix Network Programming  W.Richard Stevens  Computer Networking a top down approach  James F Kurose  Wikipedia  pubs.opengroup.org CNP Seminar by Jithin P 15