You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Mohit Anchlia <mo...@gmail.com> on 2013/01/24 16:47:01 UTC

SO_LINGER

Is SO_LINGER enabled by default?

http://activemq.apache.org/tcp-transport-reference.html

Re: SO_LINGER

Posted by Christian Posta <ch...@gmail.com>.
It's enabled only if there is a value > -1 set...

        if (soLinger > -1) {
            sock.setSoLinger(true, soLinger);
        } else if (soLinger == -1) {
            sock.setSoLinger(false, 0);
        }

Otherwise it defaults to whatever SocketFactory.getDefault().createSocket()
produces...which is probably OS dependent. On my Mac, and on Linux it seems
to default to disabled. Use this python script to check on your own system:

#!/usr/bin/env python

import socket


s = socket.socket()

socket_options = [ (getattr(socket, opt), opt) for opt in dir(socket) if opt
.startswith('SO_') ]

socket_options.sort()

for num, opt in socket_options:

    try:

        val = s.getsockopt(socket.SOL_SOCKET, num)

        print '%s(%d) defaults to %d' % (opt, num, val)

    except (socket.error), e:

        print '%s(%d) can\'t help you out there: %s' % (opt, num, str(e))



http://jonebird.com/2010/11/15/socket-option-defaults/


On Thu, Jan 24, 2013 at 10:32 AM, Mohit Anchlia <mo...@gmail.com>wrote:

> It appears from the doc that it's enabled and you have to specifically set
> it to -1
>
> Sent from my iPhone
>
> On Jan 24, 2013, at 9:19 AM, Christian Posta <ch...@gmail.com>
> wrote:
>
> > No, it's not enabled by default.
> > You can enable it with the following settings on your connection URI:
> >
> > ?soLinger=<value>
> >
> >
> > On Thu, Jan 24, 2013 at 8:47 AM, Mohit Anchlia <mohitanchlia@gmail.com
> >wrote:
> >
> >> Is SO_LINGER enabled by default?
> >>
> >> http://activemq.apache.org/tcp-transport-reference.html
> >
> >
> >
> > --
> > *Christian Posta*
> > http://www.christianposta.com/blog
> > twitter: @christianposta
>



-- 
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta

Re: SO_LINGER

Posted by Mohit Anchlia <mo...@gmail.com>.
It appears from the doc that it's enabled and you have to specifically set it to -1

Sent from my iPhone

On Jan 24, 2013, at 9:19 AM, Christian Posta <ch...@gmail.com> wrote:

> No, it's not enabled by default.
> You can enable it with the following settings on your connection URI:
> 
> ?soLinger=<value>
> 
> 
> On Thu, Jan 24, 2013 at 8:47 AM, Mohit Anchlia <mo...@gmail.com>wrote:
> 
>> Is SO_LINGER enabled by default?
>> 
>> http://activemq.apache.org/tcp-transport-reference.html
> 
> 
> 
> -- 
> *Christian Posta*
> http://www.christianposta.com/blog
> twitter: @christianposta

Re: SO_LINGER

Posted by Christian Posta <ch...@gmail.com>.
No, it's not enabled by default.
You can enable it with the following settings on your connection URI:

?soLinger=<value>


On Thu, Jan 24, 2013 at 8:47 AM, Mohit Anchlia <mo...@gmail.com>wrote:

> Is SO_LINGER enabled by default?
>
> http://activemq.apache.org/tcp-transport-reference.html
>



-- 
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta