Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #24436

Re: How keep python socket alive for ever by setting Keep alive flag.

References <44c35921-ff32-4e80-b8fd-4dd2f3960a21@googlegroups.com>
Date 2012-06-25 17:30 +0000
Subject Re: How keep python socket alive for ever by setting Keep alive flag.
From Dan Stromberg <drsalists@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1492.1340645444.4697.python-list@python.org> (permalink)

Show all headers | View raw


http://www.unixguide.net/network/socketfaq/4.7.shtml

It's better to add the ability to recreate a socket if it encounters
trouble. SO_KEEPALIVE is there to help you detect if the other end of
your connection has disappeared.

Network programming has relatively few absolutes - it's best to build
in error checking and sometimes, error responses that go beyond mere
error messages.

On Mon, Jun 25, 2012 at 5:21 PM, hisan <santosh.ssit@gmail.com> wrote:
> Hi All,
>
> I want to open a socket connection and keep it alive for ever or until i explicitly close the socket connection.
>
> below is my code though i have set keep alive flag the socket gets closed after some time .please help me out here
>
>            sb_sock = socket.socket(socket.AF_INET,
> socket.SOCK_STREAM,socket.SOL_TCP)
>            sb_sock.setsockopt( socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
>            sb_sock.connect((msg_host, host_port))
>            sb_sock.send(reg_msg)
> --
> http://mail.python.org/mailman/listinfo/python-list

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

How keep python socket alive for ever by setting Keep alive flag. hisan <santosh.ssit@gmail.com> - 2012-06-25 10:21 -0700
  Re: How keep python socket alive for ever by setting Keep alive flag. Dan Stromberg <drsalists@gmail.com> - 2012-06-25 17:30 +0000

csiph-web