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

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.kernelnewbies.org/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux