public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Chinmaya Mishra <chinmaya4@gmail.com>
To: undisclosed-recipients:;
Subject: setsockopt -  SO_REUSEADDR
Date: Wed, 26 Jul 2006 12:36:29 +0530	[thread overview]
Message-ID: <44C71475.5060005@innomedia.soft.net> (raw)

Hi all,

I am creating a socket in kernel. It is able to bind. But after abnormal
termination of the module, I am not able to bind the socket once again. 
Here i use

.......................................................................
/* create a socket */
if ((err = sock_create(AF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock)) < 0) {
    printk(KERN_INFO MODULE_NAME": Could not create a datagram socket, 
error = %d\n", -ENXIO);
    return;
}

if((err = sock->ops->setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, 
(void*)&option, sizeof(option)))<0)
             printk(KERN_INFO MODULE_NAME": Error in set socket opt for 
SO_REUSEADDR \n");

memset(&addr, 0, sizeof(struct sockaddr));
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = htonl(INADDR_ANY);
addr.sin_port = htons(7006);

if ((err = sock->ops->bind(sock, (struct sockaddr *)&addr, sizeof(struct 
sockaddr)))< 0)
{
    printk(KERN_INFO MODULE_NAME": Could not bind to socket, error = 
%d\n", -err);
    goto close_and_out;
}
 printk(KERN_INFO MODULE_NAME": listening on port %d\n", 7006);
...................................................................

It throwing the following error
    Error in set socket opt for SO_REUSEADDR
    Could not bind to socket, error = 98


Can you tell me what i am missing. Just I want to reuse the bind same 
address once again in the
same port.


Thanks.
Chinmaya

                 reply	other threads:[~2006-07-26  6:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44C71475.5060005@innomedia.soft.net \
    --to=chinmaya4@gmail.com \
    --cc=chinmaya@innomedia.soft.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox