473,396 Members | 1,775 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,396 software developers and data experts.

ThreadingTCPServer, 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 ThreadingTCPServer... 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 1869
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 ThreadingTCPServer... 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****@jabberdust.com (Dustin) wrote in message news:<81**************************@posting.google. 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
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...
2
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...
5
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...
16
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...
0
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:...
3
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)....
6
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...
7
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....
0
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)...
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
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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...
0
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,...

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.