[ee122] listen()

Lisa Fowler fowler at eecs.berkeley.edu
Sun Nov 25 11:39:17 PST 2007

On Nov 25, 2007 11:27 AM, Davide Cerri <davide.cerri at gmail.com> wrote:
> Hello,
> i am not sure about listen(). In real tcp, we set a listener, and then
> we rely on select to know when to call accept. So how are we going to
> implement listen? are we just gonna bind a port and mark it somehow as
> a listener?

My understanding of these methods (and I'm sure Prof Paxson will
correct me if I'm wrong), is that listen() examines the socket,
looking for incoming SYNs.  It doesn't respond to the SYNs but leaves
them as half-open connections (in state SYN-RECEIVED).  You can
specify how many you wish to have pending using listen.  accept()
handles the rest of the handshake and moves the TCP connection into
the ESTABLISHED state.

> Also, since our system is not running at kernel level, can we use
> select the same way we did before, so that the user will call accept
> only when there is something in the buffer? My problem here is that
> the fd i return to the user is not a real fd, but a number that is
> used by my functions to store information about the socket. Do i have
> to create a my_select? and if that's the case can i just write an easy
> wrap around the real select?

Given what you just described in your system, you should create a
my_select wrapper around select.


More information about the ee122 mailing list