473,790 Members | 2,629 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sockets, select or: twisted and other file-descriptors

Hi,

I have a simple client-server app, that sits on a serial port and
communicates through that with an attached microcontroller-board. To the
outside, it exposes two sockets (file or inet) which can be connected by
clients to perform certain tasks like uploading programs, giving me a
console and resetting the board. So far, I've used threads - every incoming
connection generates one that will listen to the client socket using
socket.recv. Whatever comes from there is transmitted to the mc-board. The
answer is broadcasted to all listenig clients.

I now want to rewrite it using select and no more threads. If it was only a
network-application, I'd try to make my first steps using twisted. However,
I'm not sure if its possible to have twisteds select also take my
filedescriptors for the serial connection.

I could go for a two-thread approach, or maybe I can overload some twisted
class so that it works on my serial line as if it was a socket connection.

Any suggestions?

Regards,

Diez
Jul 18 '05 #1
1 2048
"Diez B. Roggisch" wrote:

I now want to rewrite it using select and no more threads. If it was only a
network-application, I'd try to make my first steps using twisted. However,
I'm not sure if its possible to have twisteds select also take my
filedescriptors for the serial connection.


Twisted has some (or full?) support for serial ports, so you should
investigate it more closely to see just what it does and whether that
would work for your own application.

A download is free, and you can browse the source pretty easily to
get the gist of it. I suspect you'll see right away that it is or
is not suitable.

(Of course, someone else might be able to say "yeah, it works" or something
already, but there's no real substitute for just checking for yourself.)

-Peter
Jul 18 '05 #2

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

Similar topics

4
7550
by: Julia Goolia | last post by:
hello, i read that it is bad to use threads with tkinter. so my question is how does one create a gui program with sockets? at one point you have to call mainloop() which does not return. then you are not free to do stuff with the sockets. what's up with that? thanks so much for your time!
4
2888
by: jblazi | last post by:
I am having this problem: I use Python for my teaching and right now we are trying to implement some sort of very simple graphical game the pupils can play across the Internet. For this, we use wxPython. Now it has turned out that wxPython does not implement wxWidget sockets, so we have to use Python sockets instead. Implementing a separate thread for this would be too complicated and I am going to use the wxIdle event to do the socket...
3
1714
by: Ajay | last post by:
hi! how can i stop a server socket running in a thread other than the main thread? if the server socket was a local variable of the function started by the child thread, would calling join work? thanks
5
4772
by: zxo102 | last post by:
Hi, I am doing a small project using socket server and thread in python. This is first time for me to use socket and thread things. Here is my case. I have 20 socket clients. Each client send a set of sensor data per second to a socket server. The socket server will do two things: 1. write data into a file via bsddb; 2. forward the data to a GUI written in wxpython. I am thinking the code should work as follow (not sure it is feasible)...
3
1724
by: OneMustFall | last post by:
Reciently i wrote a simple client (in twisted) using Reconnecting Factory. That client logins to my socket server.. and that`s it. Interesting thing is that it is seems that twisted client, sends some ping on a TCP level without sending any data to the socket directly. Because when i pull out cord from the ethernet card simulating network falure, client in about 10-15 seconds determines that connection lost!! (pretty cool)
6
7038
by: Maxim Veksler | last post by:
Hi, I've written this code, the general idea was to listen on all 65535 port of tcp for connection. """ #!/usr/bin/env python import socket, select def get_non_blocking_socket(port_number):
6
2384
by: geoffbache | last post by:
Hi all, I have a Python program (on UNIX) whose main job is to listen on a socket, for which I use the SocketServer module. However, I would also like it to be sensitive to signals received, which it isn't if it's listening on the socket. ("signals can only be received between atomic actions of the python interpreter", presumably - and control will not return to Python unless something appears on the socket). Does anyone have a tip of a...
0
1218
by: huisan.wang | last post by:
Hello everyone, I am writing a program with twisted and dbus and got a such problem. If i run the code as $python local_proxy.py There is an error like this: Traceback (most recent call last): File "local_proxy.py", line 608, in <module> reactor.listenTCP(143, factory)
0
231
by: James Mills | last post by:
On Fri, Sep 19, 2008 at 6:24 AM, Fredrik Lundh <fredrik@pythonware.comwrote: There is also one more alternative: pymills - current version 3.4 It has a different design goal to twisted and is in no competition with twisted, however provides: * An event framework
3
1476
by: Daniel | last post by:
Hello, I can't seem to get my sockets code to work right. Here is what I have inside my RequestHandler handle() function: total_data= data = True logger_server.debug(self.__class__.__name__ + ' set data = True')
0
9666
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
9512
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
10413
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10200
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...
1
10145
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9986
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...
1
7530
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...
0
5422
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.