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


Groups > comp.lang.python > #33531

Re: Question on Socket Timeouts

Path csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <cameron@cskk.homeip.net>
X-Original-To Python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'socket': 0.05; 'subject:Question': 0.07; "client's": 0.09; 'logic': 0.09; 'timeout': 0.09; 'cc:addr:python-list': 0.10; 'clock.': 0.16; 'connect()': 0.16; 'doesnt': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'received:202.125.174': 0.16; 'received:202.125.174.133': 0.16; 'received:boardofstudies.nsw.edu.au': 0.16; 'received:cskk.homeip.net': 0.16; 'received:edu.au': 0.16; 'received:harvey.boardofstudies.nsw.edu.au': 0.16; 'received:homeip.net': 0.16; 'received:nsw.edu.au': 0.16; 'seconds.': 0.16; 'simpson': 0.16; 'wrote:': 0.17; 'saying': 0.18; 'code.': 0.20; 'question.': 0.20; 'trying': 0.21; 'cheers,': 0.23; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'interface': 0.27; 'fine': 0.28; 'ray': 0.29; 'socket,': 0.29; 'probably': 0.29; "i'm": 0.29; 'seconds': 0.30; 'server.': 0.32; 'not.': 0.32; 'function.': 0.33; 'server': 0.35; 'data,': 0.35; 'programming.': 0.35; 'so,': 0.35; 'there': 0.35; 'but': 0.36; 'data.': 0.36; 'received:au': 0.36; 'client': 0.36; 'charset:us-ascii': 0.36; 'enough': 0.36; 'data': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'your': 0.60; 'content- disposition:inline': 0.60; 'matter': 0.61; 'close': 0.63; 'ever': 0.63; 'limit': 0.65; 'receive': 0.71; 'connection.': 0.75; 'itself?': 0.84; 'mistakes': 0.95
Date Mon, 19 Nov 2012 14:40:54 +1100
From Cameron Simpson <cs@zip.com.au>
To Abhijeet Mahagaonkar <abhi.forall@gmail.com>
Subject Re: Question on Socket Timeouts
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
In-Reply-To <CA+VcYvsRVe90igvQ4hnv0z=qVzWYvKER362ZB6+aBePGau+i6A@mail.gmail.com>
User-Agent Mutt/1.5.21 (2010-09-15)
References <CA+VcYvsRVe90igvQ4hnv0z=qVzWYvKER362ZB6+aBePGau+i6A@mail.gmail.com>
Cc Python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3810.1353296464.27098.python-list@python.org> (permalink)
Lines 30
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1353296464 news.xs4all.nl 6959 [2001:888:2000:d::a6]:38974
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:33531

Show key headers only | View raw


On 18Nov2012 03:27, Abhijeet Mahagaonkar <abhi.forall@gmail.com> wrote:
| I'm new to network programming.
| I have a question.
| 
| Can we set a timeout to limit how long a particular socket can read or
| write?

On the socket itself? Probably not. But...

| I have used a settimeout() function.
| The settimeout() works fine as long as the client doesnt send any data for
| x seconds.
| The data that I receive in the server after accept()ing a connect() from a
| client I check if the client is sending any invalid data.
| I'm trying to ensure that a client sending invalid data constantly cannot
| hold the server. So is there a way of saying I want the client to use this
| socket for x seconds before I close it, no matter what data I receive?

Not the time you set up the socket, or when you accept the client's
connection. Thereafter, ever time you get some data, look at the clock.
If enough time has elapsed, close the socket yourself.

So, not via an interface to the socket but as logic in your own code.

Cheers,
-- 
Cameron Simpson <cs@zip.com.au>

Their are thre mistakes in this sentence.
        - Rob Ray DoD#33333 <rray@linden.msvu.ca>

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


Thread

Re: Question on Socket Timeouts Cameron Simpson <cs@zip.com.au> - 2012-11-19 14:40 +1100

csiph-web