Passive and active sockets
Posted
by
davsan
on Stack Overflow
See other posts from Stack Overflow
or by davsan
Published on 2011-01-14T22:50:22Z
Indexed on
2011/01/14
22:53 UTC
Read the original article
Hit count: 297
Quoting from this socket tutorial:
Sockets come in two primary flavors. An active socket is connected to a remote active socket via an open data connection... A passive socket is not connected, but rather awaits an incoming connection, which will spawn a new active socket once a connection is established ...
Each port can have a single passive socket binded to it, awaiting incoming connections, and multiple active sockets, each corresponding to an open connection on the port. It's as if the factory worker is waiting for new messages to arrive (he represents the passive socket), and when one message arrives from a new sender, he initiates a correspondence (a connection) with them by delegating someone else (an active socket) to actually read the packet and respond back to the sender if necessary. This permits the factory worker to be free to receive new packets. ...
Then the tutorial explains that, after a connection is established, the active socket continues receiving data until there are no remaining bytes, and then closes the connection.
What I didn't understand is this: Suppose there's an incoming connection to the port, and the sender wants to send some little data every 20 minutes. If the active socket closes the connection when there are no remaining bytes, does the sender have to reconnect to the port every time it wants to send data? How do we persist a once established connection for a longer time? Can you tell me what I'm missing here?
My second question is, who determines the limit of the concurrently working active sockets?
© Stack Overflow or respective owner