472,353 Members | 1,818 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

How best to achieve asynchronous socket input and output?

I'm writing a wxPython telnet-like application that needs to be able
to send and receive data independently of each other. The asyncore
library comes close to what I want, but still requires I have a
blocked thread (the one that calls asyncore.loop() ). It also seems a
little unpredictable; one example of this is that when I based an
example around the sample HTTP client (11.23.1 in the docs),
handle_write never seemed to get called, and I had to call .send()
directly, bypassing any buffering.

Is there a better way of achieving what I want? Or something I need to
know about the asyncore library to get it to do this?

--
Ben Sizer
Jul 18 '05 #1
4 2800
On 23 Nov 2003 18:21:12 -0800, Kylotan <ky*****@hotmail.com> wrote:
I'm writing a wxPython telnet-like application that needs to be able
to send and receive data independently of each other. The asyncore
library comes close to what I want, but still requires I have a
blocked thread (the one that calls asyncore.loop() ). It also seems a
little unpredictable; one example of this is that when I based an
example around the sample HTTP client (11.23.1 in the docs),
handle_write never seemed to get called, and I had to call .send()
directly, bypassing any buffering.

Is there a better way of achieving what I want? Or something I need to
know about the asyncore library to get it to do this?


I usually jump immediately to select, which maps almost directly to select(2),
giving a lot of control, and lack of portability for non-unix systems.

In the context of GUI's, maybe you can get the eventloop of wxpython to
wait for file I/O on the sockets, some GUI libraries provide such a hook
(GUI handling in the end means waiting for data from the X11 server, ie
a select-like thing).
Otherwise you must poll, or use a seperate thread.

--
Albert
--
Unlike popular belief, the .doc format is not an open publically available format.
Jul 18 '05 #2
On Sun, Nov 23, 2003 at 06:21:12PM -0800, Kylotan wrote:
I'm writing a wxPython telnet-like application that needs to be able
to send and receive data independently of each other. The asyncore
library comes close to what I want, but still requires I have a
blocked thread (the one that calls asyncore.loop() ). It also seems a
little unpredictable; one example of this is that when I based an
example around the sample HTTP client (11.23.1 in the docs),
handle_write never seemed to get called, and I had to call .send()
directly, bypassing any buffering.

Is there a better way of achieving what I want? Or something I need to
know about the asyncore library to get it to do this?


You can use Twisted to do this, but unfortunately its builtin wxpython
support isn't very good. There is however a workaround for it:
http://aspn.activestate.com/ASPN/Coo.../Recipe/181780

(There's also a more comprehensive example app here:
http://aspn.activestate.com/ASPN/Coo.../Recipe/203471)

If you don't want to switch to Twisted, perhaps a similar approach would
work for asyncore?

-Andrew.
Jul 18 '05 #3
Kylotan wrote:
I'm writing a wxPython telnet-like application that needs to be able
to send and receive data independently of each other. The asyncore
library comes close to what I want, but still requires I have a
blocked thread (the one that calls asyncore.loop() ).


using a timer to poll asyncore tends to work pretty well.

for examples, see "Managing Downloads" and "Keeping the network
traffic going" on this page:

http://effbot.org/zone/effnews-3.htm

(you can search for "poll" to find the relevant portions)

</F>

Jul 18 '05 #4
"Fredrik Lundh" <fr*****@pythonware.com> wrote in message news:<ma*************************************@pyth on.org>...
Kylotan wrote:
I'm writing a wxPython telnet-like application that needs to be able
to send and receive data independently of each other. The asyncore
library comes close to what I want, but still requires I have a
blocked thread (the one that calls asyncore.loop() ).


using a timer to poll asyncore tends to work pretty well.

for examples, see "Managing Downloads" and "Keeping the network
traffic going" on this page:

http://effbot.org/zone/effnews-3.htm

(you can search for "poll" to find the relevant portions)


Ok, so from what you're saying, and what the others in the thread have
said, it seems like I can't get around having to poll the sockets
periodically somehow, in another thread. I guess I will just make a
thread for all my sockets and pass it relevant callbacks for whenever
select decides that a socket has some data incoming.

--
Ben Sizer
Jul 18 '05 #5

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

Similar topics

0
by: TJ | last post by:
Dear Sir/Madm Environmen ..NET runtime 1. IE 6. I made one User Control form to host in Internet Explorer class MyUserControl : UserControl...
2
by: Winston Nimchan | last post by:
Hi: I am trying to develop a server application that listens for incoming network request and processes these requests. Processing request...
1
by: Chan | last post by:
Building an Asyc Socket DLL using C#, I followed MS .NET FRAMEWORK library sample (see "Asynchronous Client Socket Example") and created a DLL...
7
by: Colin | last post by:
I'm writing a little console socket server but I'm having some difficulty. Can I ask your advice - where is the best place to get some help on that...
2
by: Macca | last post by:
My app has an asynchronous socket server. It will have 20 clients connected to the server. Each client sends data every 500 millisecondsThe...
4
by: Engineerik | last post by:
I am trying to create a socket server which will listen for connections from multiple clients and call subroutines in a Fortran DLL and pass the...
0
by: doc | last post by:
Hi Hard to know where to post this and I don't want to double post it - please move it if you need to, I am trying to connect a Flash client...
6
by: Pat B | last post by:
Hi, I'm writing my own implementation of the Gnutella P2P protocol using C#. I have implemented it using BeginReceive and EndReceive calls so as...
2
by: Nicolas Le Gland | last post by:
Hello everyone here. This is my first post in this newsgroup, I hope I won't be to much off-topic. Feel free to redirect me to any better group....
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

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.