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 6757973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:43:08+00:00 2026-05-26T13:43:08+00:00

My goal is to create telnet clients as endpoints per the TCP4ClientEndpoint implementation. Here’s

  • 0

My goal is to create telnet clients as endpoints per the TCP4ClientEndpoint implementation.

Here’s what Im doing:

class TelnetClient( TelnetProtocol ):
    ...

factory = Factory()
factory.protocol = TelnetClient
point = TCP4ClientEndpoint( reactor, x.x.x.x, 23 )
defer = point.connect( factory )

defer.addCallback( todo )
reactor.run

The TelnetClient class handles authentication, logging in, firing commands, etc.

when I use this approach, I can read some output off of dataReceived, but it’s giberish.

The telnet client functions as expected when it is constructed by a Factory and then reactor.connectTCP(...) is called with the Factory.

What is it that Im doing wrong here?

Thanks!

EDIT 1 connecting TelnetClient to factory.protocol via TelnetProtocol

class TelnetClient( TelnetProtocol ):
    ...

factory = Factory()
factory.protocol = TelnetTransport( TelnetClient )
point = TCP4ClientEndpoint( reactor, x.x.x.x, 23 )
defer = point.connect( factory )

defer.addCallback( todo )
reactor.run

EDIT 2 solved. The final piece was ClientFactory.

class TelnetClient( TelnetProtocol ):
    ...

factory = ClientFactory()
factory.protocol = TelnetTransport( TelnetClient )
point = TCP4ClientEndpoint( reactor, x.x.x.x, 23 )
defer = point.connect( factory )

Solving this problem was two fold.

  1. Since we want a telnet client, we need to ensure that the protocol is an instance of TelnetProtocol.

  2. The factory must be of ClientFactory. If we look at the source of twisted.internet.endoints, we see that the factory we pass in to the endpoints is wrapped in _WrappingFactory, which is descended from ClientFactory. If this factory we pass in does not have the same attributes as ClientFactory, then the _wrappedFactory will cause AttributeErrors when it attempts to call methods of ClientFactory

  • 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-26T13:43:09+00:00Added an answer on May 26, 2026 at 1:43 pm

    You’re correct thatconnectTCP and endpoint.connect are functionally the same (for the most part).

    Assuming that TelnetProtocol is twisted.conch.telnet.TelnetProtocol, the problem here is that TelnetProtocol is not really supposed to connect directly to a TCP transport, it’s supposed to connect to a twisted.conch.telnet.TelnetTransport. That “gibberish” in dataReceived that you’re seeing are the actual telnet protocol bytes, which are supposed to be parsed by a twisted.conch.telnet.TelnetTransport (which is itself an IProtocol) in order to call methods like enableLocal and enableRemote on the TelnetTransport.

    I would guess that in your connectTCP-based example, you are probably instantiating a TelnetTransport and setting its .protocol attribute to point at a TelnetProtocol.

    Basically, make sure that the Factory object that you’re passing in has exactly the same protocol attribute as the ClientFactory you’re using in your connectTCP example.

    In the future, also, please include complete, runnable code examples so that we can run them and see what happens rather than guessing :-).

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

Sidebar

Related Questions

The goal is to create a mock class which behaves like a db resultset.
My goal here is to create a very simple template language. At the moment,
For example my table is here>> CREATE TABLE tProject( name nvarchar(1000), Goal ntext, Activities
My goal is to create a Chirper class. A chirper should be able to
Hi here's the goal: to create an automatic bit of content that toggles open
AS3.0 newbie here. My goal: To create a side-scrolling motocross game (horizontal - already
My goal is to create a trait that a case class can extend, which
My goal is to create (or use existing) an InputStream implementation (say, MergeInputStream) that
Goal: Create Photomosaics programmatically using .NET and C#. Main reason I'd like to do
The goal: To create a .NET dll i can reference from inside SQL Server

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.