listen and accept function

14
2 CNP Seminar by Jithin P What is a socket It is an interface between application layer and transport layer within a host.

Upload: jithin-parakka

Post on 17-Dec-2014

1.493 views

Category:

Education


4 download

DESCRIPTION

This PPT is about TCP Listen and accept function and it is explaining three way handshaking also

TRANSCRIPT

Page 1: Listen and accept function

CNP Seminar by Jithin P 2

What is a socket ?

It is an interface between application layer and transport layer within a host.

Page 2: Listen and accept function

CNP Seminar by Jithin P 3

Application Layer

SocketTransport Layer

Page 3: Listen and accept function

CNP Seminar by Jithin P 4

Why socket ?

For IdentificationKannadasan Yamuna

?

Page 4: Listen and accept function

CNP Seminar by Jithin P 5

Why socket ?

Hostel Name + Room No

IP address + Port number

Socket

Page 5: Listen and accept function

CNP Seminar by Jithin P 6

listen() accept()

Page 6: Listen and accept function

CNP Seminar by Jithin P 8

listen()Called only by TCP serverPerforms two actions

Convert the socket in to passive socket Specify the maximum number of connections the

kernel should queue

Page 7: Listen and accept function

CNP Seminar by Jithin P 9

For a listening socket the kernel maintains two queuesAn incomplete connection queue

Waiting for 3-way handshakeA complete connection queue

Completed 3-way handshake

Page 8: Listen and accept function

CNP Seminar by Jithin P 10

client server

Connect called

Connect returns

Create entry on incomplete queue

Entry moved from incomplete queue to complete queue

SYN 100

SYN 240, ACK 101

ACK 241

3-way handshaking

Page 9: Listen and accept function

CNP Seminar by Jithin P 11

int listen(int sockfd, int backlog)

Page 10: Listen and accept function

CNP Seminar by Jithin P 12

Questions ?What is the default size of backlog ?Which queue is longest one

(complete/incomplete) ?What will happen when queue is full ?

Page 11: Listen and accept function

CNP Seminar by Jithin P 13

accept()

Completed connection queue

Incomplete connection queue

Arriving SYN

Page 12: Listen and accept function

CNP Seminar by Jithin P 14

accept()

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

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

Page 13: Listen and accept function

CNP Seminar by Jithin P 15

References Unix Network Programming

W.Richard Stevens

Computer Networking a top down approach James F Kurose

Wikipedia pubs.opengroup.org

Page 14: Listen and accept function

CNP Seminar by Jithin P 16

Questions