setsockopt - SO_REUSEADDR



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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • BIND 9.5.2rc1 is now available.
    ... BIND 9.5.2rc1 is now available. ... triggering an assertion failure in ... API and glibc hides parts of the IPv6 Advanced Socket ... need to tweak ISC_SOCKET_MAXSOCKETS at compilation time ...
    (comp.protocols.dns.bind)
  • BIND 9.5.2 is now available.
    ... BIND 9.5.2 is now available. ... triggering an assertion failure in ... API and glibc hides parts of the IPv6 Advanced Socket ... need to tweak ISC_SOCKET_MAXSOCKETS at compilation time ...
    (comp.protocols.dns.bind)
  • BIND 9.4-ESVb1 is now available.
    ... BIND 9.4-ESVb1 is a extended release version beta for BIND 9.4. ... API and glibc hides parts of the IPv6 Advanced Socket ... WARNING: API CHANGE: over memory callback ... If allow-recursion is not set in named.conf then ...
    (comp.protocols.dns.bind)
  • BIND 9.5.2b1 is now available.
    ... BIND 9.5.2b1 is a maintenance release for BIND 9.5. ... triggering an assertion failure in ... API and glibc hides parts of the IPv6 Advanced Socket ... need to tweak ISC_SOCKET_MAXSOCKETS at compilation time ...
    (comp.protocols.dns.bind)
  • Re: Java Socket Constructor
    ... bind() simply binds a socket to an interface/port locally for both client ... After that you can connectto a server. ...
    (comp.lang.java.programmer)