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
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