Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > RE: Newbie question: SOLVED (how to keep a socket listening), but still some questions

Reply
Thread Tools

RE: Newbie question: SOLVED (how to keep a socket listening), but still some questions

 
 
Giovanni Tumiati
Guest
Posts: n/a
 
      06-25-2005
To all those that replied - thank you.
I solved the problem I posted earlier.
I'm embarrassed to admit that it was caused by the following:
....
while 1: ## wait for a connection
try:
#...waiting for connection
(client, address)=sa.accept()
except sa.timeout: <--------------there is no such exception for a socket!
#...waiting for connection timeout
continue
except:
continue ## for now ignore this!
....

There is no "timeout exception" on a socket so the exception was failing.
I don't remember where I read about it, but now I cannot find such an
exception...I guess I dreamt it up

However some of my questions still remain from earlier post:
(1) What is the difference between / how should they be used?
- setdefaulttimeout(timeout)
- settimeout(value)

(2)Does one have to do a socket.shutdown() before one does a socket.close??

Again thanks!
pete

 
Reply With Quote
 
 
 
 
Peter Hansen
Guest
Posts: n/a
 
      06-25-2005
Giovanni Tumiati wrote:
> However some of my questions still remain from earlier post:
> (1) What is the difference between / how should they be used?
> - setdefaulttimeout(timeout)
> - settimeout(value)


I think it's basically as you surmised. Calling
socket.setdefaulttimeout() (where "socket" is the module itself) sets up
the default timeout value for all subsequently created sockets. Calling
sock.settimeout() (where "sock" is a specific socket object) changes the
timeout value on that socket alone.

> (2)Does one have to do a socket.shutdown() before one does a socket.close??


Not normally, AFAIK.

-Peter
 
Reply With Quote
 
 
 
 
Grant Edwards
Guest
Posts: n/a
 
      06-25-2005
On 2005-06-25, Giovanni Tumiati <(E-Mail Removed)> wrote:

> However some of my questions still remain from earlier post:
> (1) What is the difference between
> - setdefaulttimeout(timeout)


That sets the timeout for any sockets created in the future.

> - settimeout(value)


That sets the timeout for an individual socket.

> how should they be used?


Use the former if you want the same timeout for all sockets.
Use the latter if if you want to set them individually for each
socket.

Is the documentation unclear?

> (2)Does one have to do a socket.shutdown() before one does a
> socket.close??


No.

[I've never figured out why one would do a shutdown RDWR
rather than close the connection, but I haven't put a lot of
thought into it.]

--
Grant Edwards grante Yow! -- I love KATRINKA
at because she drives a
visi.com PONTIAC. We're going
awaynow. I fed the cat.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How keep python socket alive for ever by setting Keep alive flag. hisan Python 1 06-25-2012 05:30 PM
RE: Populating a dictionary, fast [SOLVED SOLVED] Michael Bacarella Python 26 11-20-2007 03:02 PM
Re: Newbie question: SOLVED (how to keep a socket listening),but still some questions Jp Calderone Python 2 06-25-2005 02:29 AM



Advertisments