Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TCP - Listen vs Accept

Status
Not open for further replies.

Jazz87

Programmer
Jan 5, 2011
1
IE
Hello, I am new to the forum and wondering if I could have an answer to a basic socket problem, namely whats the difference between listen() and accept().

From my understanding:

Listen(listenfd, ListenQueue)

This process turns the created socket into a listening socket, and the ListenQueue is the place where incoming requests are buffered.

connfd = accept(listenfd, (SA*)NULL,NULL)

This where a connection request is dequeued, and binded with a new socketfd to create a new connection to send over.

My problem lies in the question:

Why is it not appropriate to write to the listening socket?Also, if anyone could clearly explain how the client information is placed in the queue in the first place, and then retrieved, that would be of tremendous help.

Thanks,
Jazz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top