473,394 Members | 1,740 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

One last thing about SocketServer

rbt
I've read more about sockets and now, I have a better understanding of
them. However, I still have a few SocketServer module questions:

When used with SocketServer how exactly does socket.setdefaulttimeout()
work? Does it timeout the initial connect request to the socket server
or does it timeout the session between the connecting client socket and
the client socket the server generated to handle the incoming request?

Also, since the *only* thing a 'socket server' does is to create 'client
sockets' to handle requests, how do I use socket object features on
these generated clients to manage and/or monitor them?

The SocketServer module is great, but it seems to hide too many details
of what it's up to!

Thanks,
rbt

Oct 10 '05 #1
1 1578
rbt wrote:
I've read more about sockets and now, I have a better understanding of
them. However, I still have a few SocketServer module questions:

When used with SocketServer how exactly does socket.setdefaulttimeout()
work? Does it timeout the initial connect request to the socket server
or does it timeout the session between the connecting client socket and
the client socket the server generated to handle the incoming request?
setdefaulttimeout() simply sets the default timeout for all sockets
created thereafter. This timeout applies to any socket operation, I
believe (though I am unsure about "accept()").
Also, since the *only* thing a 'socket server' does is to create 'client
sockets' to handle requests, how do I use socket object features on
these generated clients to manage and/or monitor them?
When the accept() call on a socket returns a tuple(socket, address): the
first element of the returned tuple is the socket you use to communicate
with that particular client (in other words, it represents the server
end of the connection that's just been accept()ed).

So you can read and write that socket to communicate with that client
over that specific connection. Of course, if you don't use either the
ThreadingMixIn or the ForkingMixIn then communication with one client
will effectively stop you form accept()ing any more connections, hence
the need for the mix-in classes.
The SocketServer module is great, but it seems to hide too many details
of what it's up to!

Well, of course, that is what abstractions are for! You should bear in
mind that SocketServer isn't necessarily the most efficient or effective
way to handle multiple clients concurrently, but it's very convenient
when you are just getting started.

Later you might want to consider an asyncore-based approach, or perhaps
using the Twisted package. Both of these solutions are a little more
robust for production code.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

Oct 10 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ergin Aytac | last post by:
I'm trying to run a script written in python and have some socket connection problems. I cutted the origin script (more than 1000 lines) so it is only the part of the connection and there is no...
0
by: Adil Hasan | last post by:
Hello Fred, I just ran across your question. I think that the following code will work: ----- SERVER CODE ------ import SocketServer import time class...
5
by: missiplicity | last post by:
Hi, I am newbie to Python language and am taking my baby steps. I am using Python2.4 from ActiveState on W2K. I am trying to create a simple SocketServer program. Just adding the following 2 lines...
12
by: Paul Rubin | last post by:
Let's say you have a SocketServer with the threading mix-in and you run serve_forever on it. How can you shut it down, or rather, how can it even shut itself down? Even if you use a...
3
by: Magnus Lycka | last post by:
I have a socket server like below which I want to exit when it's out of data. If I interrupt the client, I'll get a broken pipe on the server side, and after a Ctrl-C, I can restart the server...
0
by: Tomi Hautakoski | last post by:
Hello, I'm a Python newbie trying to figure out how to use SocketServer with IPv6. I would like to set up a TCPServer working like below but how to tell SocketServer I need to use AF_INET6? ...
5
by: eliben | last post by:
Hello, I have a small wxPython application. Today I was trying to add some RPC capability to it, so I implemented an instance of SimpleXMLRPCServer that runs in a separate thread when invoked...
1
by: Okko Willeboordse | last post by:
All, With Python 2.5 SocketServer features the shutdown method that can be called from another thread to stop the serve_forever loop. However; When the shutdown method is called before...
1
by: Okko Willeboordse | last post by:
Hello, SocketServer.ThreadingTCPServer accepts connections (clients can connect) before and after it's server_forever method is called, see below for an example. IMHO it should only accept...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.