Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6904055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:00:08+00:00 2026-05-27T08:00:08+00:00

I discovered twisted half-way through developing a network application. I had a working Client

  • 0

I discovered twisted half-way through developing a network application. I had a working Client and Server using raw socket communication, but have opted to use Twisted in order to handle multiple connections asynchronously on the Server side. The twisted server works fine with the following raw-socket client class connecting to it:

class Client:
  def __init__(self, backend, port=22220):
    import socket
    self.role_buf = 4096
    self.buf = 1024
    self.addr = (backend, port)
    self.TCPSock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    self.TCPSock.connect(self.addr)

  def getRoleList(self):
    self.TCPSock.send("RLP")
    data = self.TCPSock.recv(self.role_buf)
    return data.split("|")

  def getServer(self, roleindex=0):
    self.TCPSock.send(roleindex)
    ip = self.TCPSock.recv(self.buf)
    self.TCPSock.close()
    return ip

What I’d like to do is refactor the client code using Twisted’s clean socket and reactor abstraction. I’d like to be able to instantiate the client class in my Qt-based client GUI (Using PyQt) to gather event-driven (asynchronous) input from the user by calling getRoleList() and getserver() from the PyQt based client code. I don’t want to use the PyQt socket/reactor implementation, I’d like to use a single library for my network communication.

Is this possible, and if so how should I do it? I think it should be, but having spent quite a while researching and reading twisted documentation, including these excellent tutorials I can’t seem to glean from them exactly how to go about implementing a solution. Maybe I’m doing something silly and I need my hand slapped?

Typical Server/Client Interaction:

The server is always listening on port 22220, and when it receives a “role list request” from the client, it pushes it’s (dynamic) list of role choices to the client. The client then displays these role choices to the user in a GUI, the user selects the single role they would like, then the client sends that request back to the server. The server then responds with data appropriate to the user’s specific selection.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:00:09+00:00Added an answer on May 27, 2026 at 8:00 am

    Your best bet for quick Twisted client and server info is to look at the Twisted How To docs:

    http://twistedmatrix.com/documents/current/core/howto/index.html

    In particular: Writing a TCP Server (which you seem to have working)

    and: Writing a TCP Client

    After you have your head wrapped around that, get the third party qtreactor from here:

    https://github.com/ghtdak/qtreactor

    and use that to integrate Qt and twisted together in your client. This reactor allows PyQt and Twisted to run side-by-side in the same application without blocking each other.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I share a blob of data using a Twisted server, while at
I discovered that one of the tables of a legacy db I'm working on
Today I discovered that my fresh installation of Apache HTTP Server is able to
I discovered a nice abstraction whereby I can read in data from UDP using
I discovered(*) today that, depending on the server, my TSQL commands were case-sensitive, meaning
I have just discovered that SQL Server CE doesn't allow you to batch queries.
i discovered a strange performance leak in one statement of our application, which runs
I just discovered ParseKit but can't seem to get it working on a simple
I discovered this while using ruby printf, but it also applies to C's printf.
I discovered template metaprogramming more than 5 years ago and got a huge kick

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.