Re: How to implement listen and accept routines (kernel)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 21 Feb 2002, Marek Zawadzki wrote:

[...]
> I want to make my protocol connection-oriented. I am really stuck with
> listen and accept routines :-(.

I was able to narrow the problem a bit. My main question now is:
Where is the queue with pending connections located? What adds incoming
connections to this queue? Briefly: how do I get next pending socket?

Please take a look at my listen and accept routines and give me some
advice how to complete them ('accept' especially). Thanks...



int listen_start(struct sock *sk)
{
        sk->state = TCP_LISTEN;
        if (sk->prot->get_port(sk, sk->num) == 0) {
                sk->sport = htons(sk->num);
                sk_dst_reset(sk);
                return 0;
        }

        sk->state = TCP_CLOSE;

        return -EADDRINUSE;
}


struct sock *accept(struct sock *sk, int flags, int *err)
{
        int error;

        if (sk->state != TCP_LISTEN) {
                error = -EINVAL;
                *err = error;
                return NULL;
        }

        error = -EAGAIN;
        *err = error;
        return NULL;
}

-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux