473,395 Members | 1,637 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,395 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 2848
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 ... void ConnectToServer()
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 involves analyzing the packet, applying business rules,...
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 called MSSock. I then reference MSSock in a .exe c#...
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 topic? It would be nice if some people who knew...
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 Connections once established will not be closed unless...
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 results back to the client. The asynchronous socket...
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 socket (XML) to a php socket server (using Flash 8 and...
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 not to block when waiting for data from the...
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. I am getting strange timing issues when...
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:
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.