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