473,657 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ThreadingTCPSer ver, asyncore and Client-to-Client communication

I've been trying to create a "byte streaming server", it's basically a
chat server, but I'd like to use it for transfering large amounts of
data between two connected clients. Sounds simple enough, but I'm
having a difficult time implementing it.

If Client #1 connects, then that thread is consumed with listening for
data from that client. If Client #2 connects, that client is on a
different thread, and therefore I don't see how I can have data sent
from Client #1 to be streamed down to Client #2. (and how can client
process #1 accept data from client #2 because it's listening to client
#1?) Obviously I'm missing something.

I've looked at asyncore/asynchat, as well as ThreadingTCPSer ver... but
there's something I'm missing. Is there a simple way to have an
object listen over two ports, and what comes into one port will be
sent down the another?

Any advice, or a good swift kick in the right direction would be
appreciated.
Dustin
Jul 18 '05 #1
2 1882
Dustin wrote:
[...]
If Client #1 connects, then that thread is consumed with listening for
data from that client. If Client #2 connects, that client is on a
different thread, and therefore I don't see how I can have data sent
from Client #1 to be streamed down to Client #2. [...] I've looked at asyncore/asynchat, as well as ThreadingTCPSer ver... but
there's something I'm missing. Is there a simple way to have an
object listen over two ports, and what comes into one port will be
sent down the another?


Yes; look up the select module in the standard library (on which
asyncore is built).

Also, note that sockets are not bound to a single thread. If
you don't want to use select, you might have one thread that
reads from socket x and writes to socket y, and another thread
that reads from y and write to x. Some perfectly reasonable
systems have a reading thread and a writing thread for each
socket.
--
--Bryan
Jul 18 '05 #2
du****@jabberdu st.com (Dustin) wrote in message news:<81******* *************** ****@posting.go ogle.com>...
I've been trying to create a "byte streaming server", it's basically a
chat server, but I'd like to use it for transfering large amounts of
data between two connected clients. Sounds simple enough, but I'm
having a difficult time implementing it.


investigate os.select; you don't even need multiple threads for this operation.
Jul 18 '05 #3

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

Similar topics

0
2734
by: Paolo Invernizzi | last post by:
Spambayes CVS, Python 2.2.3, FreeBSD 5.1 On my machine I'm lunching the pop3proxy with cron at startup, and all is fine. But... sometimes during startup, or after a one or two days, the process exits with the following error... Is a BSD select related problem? Is an asyncore problem? Is a spambayes problem?
2
1462
by: Freddie | last post by:
Hi, I've been playing around with asyncore for one of my projects, currently using it to fetch HTTP pages without blocking things. Having a few issues, though. With the code below, I would start a new async_http instance with "async_http(url, returnme)". If it encountered a redirect, that object would start a new one as "async_http(url, returnme, seen=self._seen)" to remember what URLs it had seen. The problem is that after a while...
5
5932
by: David M. Wilson | last post by:
Hi peeps, I finally got around recently to doing something serious using Python for serving network clients asynchronously, deciding on asyncore as my starting point. After 2 days or so of fiddling about, I have decided, as many before me have, that the current asyncore module is the most inflexible, brain-dead, and useless module to be found on the face of the earth!
16
3260
by: Rob Snyder | last post by:
Greetings - I've embarked on a small learning project, trying to get a better grasp of the asyncore and asynchat modules. The project involves building a simple instant messenger application for use on our LAN - nothing heavy duty, as 99% of my reason for doing this is just to learn. I got my server portion working well, and I think I understand the basics. Where I'm getting stuck is on the client side, where I'm trying to involve...
0
981
by: Ktm | last post by:
Hello, i tried the demo echod_asyn.py without any certification verification (I modified echod_lib.py) and when I connect on the port with stunnel I've got the following error : error: uncaptured python exception, closing channel <__main__.ssl_echo_channel connected 127.0.0.1:34593 at 0xb7c5560c> (M2Crypto.SSL.SSLError:unexpected record
3
3660
by: Jos | last post by:
Hello. I'm using the asyncore and _chat modules to create a network server. I also have, running in a separate thread(s), a "producer" which needs to "push" data onto the network connection(s). (This is all for a multi-player game server, so the threads would be individual games, that need to update the players when new events happen in the game) I currently have a module level list of async_chat instances, which the thread then reads...
6
3496
by: KraftDiner | last post by:
If you don't know how long your input data is going to be how can you at least treat it a text line at a time... like looking for new line in the data... Right now recv blocks. Yes I could do a select, but the examples seem a bit complicated for a simple line oriented input...
7
2650
by: Paul Kozik | last post by:
I am working on the networking code for a small Multiplayer RPG I'm working on. I currently have some basic code using threads, but it seems like asyncore would be far better suited for my needs. However, I have trouble finding a solid example for what I need. Python.org and other sites provide simple examples, but they appear more intended for servers that simply send one peice of data to the client. I want to have a server program that...
0
915
by: davy zhang | last post by:
import asyncore, asynchat import os, socket, string PORT = 8000 class HTTPChannel(asynchat.async_chat): def __init__(self, server, sock, addr): asynchat.async_chat.__init__(self, sock) self.set_terminator("\r\n")
1
4479
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 connections while server_forever is running. Kind regards,
0
8394
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8306
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8732
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8605
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7327
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6164
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.